-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.php
244 lines (211 loc) · 9.35 KB
/
init.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
<?php
// kleeja plugin
// developer: kleeja team
// prevent illegal run
if (! defined('IN_PLUGINS_SYSTEM'))
{
exit;
}
// plugin basic information
$kleeja_plugin['phpbb_integration']['information'] = [
// the casual name of this plugin, anything can a human being understands
'plugin_title' => [
'en' => 'phpBB Integration',
'ar' => 'التكامل مع phpBB'
],
// who wrote this plugin?
'plugin_developer' => 'kleeja.com',
// this plugin version
'plugin_version' => '1.0.5',
// explain what is this plugin, why should i use it?
'plugin_description' => [
'en' => 'phpBB Membership Integration',
'ar' => 'التكامل مع عضويات phpBB'
],
//settings page, if there is one (what after ? like cp=j_plugins)
'settings_page' => 'cp=phpbb_settings',
// min version of kleeja that's required to run this plugin
'plugin_kleeja_version_min' => '3.1.0',
// max version of kleeja that support this plugin, use 0 for unlimited
'plugin_kleeja_version_max' => '3.9.9',
// should this plugin run before others?, 0 is normal, and higher number has high priority
'plugin_priority' => 0
];
//after installation message, you can remove it, it's not requiered
$kleeja_plugin['phpbb_integration']['first_run']['ar'] = '
يجب ضبط إعدادات الإضافة من خلال صفحة الإضافة لضمان عملها وتفعيلها <br><br>
شكراً لاستخدامك الإضافة، قم بمراسلتنا بالأخطاء عند ظهورها على: <br>
https://github.com/kleeja-official/kleeja/issues
';
$kleeja_plugin['phpbb_integration']['first_run']['en'] = '
In order for this plugin to works, you need to adjust its settings from its page.<Br><br>
Thank you for using our plugin. If you encounter any bugs and errors, report them on: <br>
https://github.com/kleeja-official/kleeja/issues
';
// plugin installation function
$kleeja_plugin['phpbb_integration']['install'] = function ($plg_id) {
//new options
$options = [
'phpbb_intr_enabled' =>
[
'value' => '0',
'plg_id' => $plg_id,
'type' => 'phpbb_integration'
],
'phpbb_intr_path' =>
[
'value' => '../phpbb',
'plg_id' => $plg_id,
'type' => 'phpbb_integration'
],
'phpbb_intr_link' =>
[
'value' => 'http://example.com/phpbb',
'plg_id' => $plg_id,
'type' => 'phpbb_integration'
],
'phpbb_intr_api_key' =>
[
'value' => sha1(mt_rand()),
'plg_id' => $plg_id,
'type' => 'phpbb_integration'
],
];
add_config_r($options);
//new language variables
add_olang([
'R_PHPBB_SETTINGS' => 'إعدادات phpBB',
'PHPBB_INTR_ENABLE' => 'تفعيل التكامل مع عضويات phpBB',
'PHPBB_INTR_PATH' => 'مسار مجلد phpBB بالنسبة لمجلد كليجا',
'PHPBB_INTR_PATH_EXP' => 'غير اجباري, سنستخدمه لمحاولة نسخ ملف kjauth.php لمجلد المنتدى المربوط به إن كان في نفس الإستضافة.',
'PHPBB_INTR_LINK' => 'رابط منتدى phpBB',
'PHPBB_INTR_API_KEY' => 'مفتاح الربط العشوائي',
'PHPBB_INTR_KJAUTH_FILE_EXP' => 'قم بنسخ المحتويات ووضعها في ملف باسم kjauth.php في مجلد المنتدى المربوط فيه.',
'PHPBB_INTR_REGENERATE' => 'إعادة إنشاء مفتاح الربط',
'PHPBB_INTR_KJAUTH_FILE' => 'إنشاء ملف kjauth.php',
'PHPBB_INTR_REGENERATE_NOTE' => 'هل أنت متأكد؟ عملية إعادة الإنشاء للمفتاح تتطلب منك نسخ المفتاح ووضفعه في ملف kjauth.php من جديد!',
'PHPBB_INTR_TEST' => 'فحص التكامل',
'PHPBB_INTR_TEST_NOTE' => 'لتفعيل التكامل قم بعمل فحص للتكامل.',
'PHPBB_INTR_TEST_NOTE_ERR' => 'فشل الإتصال، قم بالتأكد من الإعدادات قبل التجربة مرة أخرى!',
'PHPBB_INTR_TEST_NOTE_SUCCESS' => 'الاتصال ناجح! يمكنك الآن تفعيل التكامل لو أردت ذلك.',
],
'ar',
$plg_id);
add_olang([
'R_PHPBB_SETTINGS' => 'phpBB Intergration',
'PHPBB_INTR_ENABLE' => 'Enable phpBB membership Integration',
'PHPBB_INTR_PATH' => 'phpBB relative path',
'PHPBB_INTR_PATH_EXP' => 'Optional, we will try to copy kjauth.php to phpbb folder if in same hosting space.',
'PHPBB_INTR_LINK' => 'Link to phpBB forum',
'PHPBB_INTR_API_KEY' => 'Integration generated key',
'PHPBB_INTR_KJAUTH_FILE_EXP' => 'With this content, create a file called kjauth.php in the integrated-with phpBB folder.',
'PHPBB_INTR_REGENERATE' => 'Re-generate Api Key',
'PHPBB_INTR_KJAUTH_FILE' => 'Create kjauth.php file',
'PHPBB_INTR_REGENERATE_NOTE' => 'Are you sure? regenerating the key will disable current integration and will require copying the key to kjauth.php again!',
'PHPBB_INTR_TEST' => 'Test Integration',
'PHPBB_INTR_TEST_NOTE' => 'In order to enable integration, test the integration first.',
'PHPBB_INTR_TEST_NOTE_ERR' => 'Connection failed! Check settings and test again!',
'PHPBB_INTR_TEST_NOTE_SUCCESS' => 'Connection succeeded! You can enable integration now if you want.',
],
'en',
$plg_id);
};
//plugin update function, called if plugin is already installed but version is different than current
$kleeja_plugin['phpbb_integration']['update'] = function ($old_version, $new_version) {
// if(version_compare($old_version, '0.5', '<')){
// //... update to 0.5
// }
//
// if(version_compare($old_version, '0.6', '<')){
// //... update to 0.6
// }
//you could use update_config, update_olang
};
// plugin uninstalling, function to be called at uninstalling
$kleeja_plugin['phpbb_integration']['uninstall'] = function ($plg_id) {
//delete options
delete_config([
'phpbb_intr_enabled',
'phpbb_intr_path',
'phpbb_intr_link',
'phpbb_intr_api_key',
]);
//delete language variables
foreach (['ar', 'en'] as $language)
{
delete_olang(null, $language, $plg_id);
}
};
// plugin functions
$kleeja_plugin['phpbb_integration']['functions'] = [
//add to admin menu
'begin_admin_page' => function ($args) {
$adm_extensions = $args['adm_extensions'];
$ext_icons = $args['ext_icons'];
$adm_extensions[] = 'phpbb_settings';
$ext_icons['phpbb_settings'] = 'users';
return compact('adm_extensions', 'ext_icons');
},
//add as admin page to reach when click on admin menu item we added.
'not_exists_phpbb_settings' => function() {
$include_alternative = dirname(__FILE__) . '/phpbb_settings.php';
return compact('include_alternative');
},
'data_func_usr_class' => function ($args) {
global $config;
if (defined('DISABLE_INTR') || $config['phpbb_intr_enabled'] != 1)
{
return;
}
$return_now = true;
$login_status = phpbb_auth_login($args['name'], $args['pass'], $args['expire'], $args['hashed'], $args['loginadm']);
return compact('return_now', 'login_status');
},
'auth_func_usr_class' => function ($args) {
global $config;
if (defined('DISABLE_INTR') || $config['phpbb_intr_enabled'] != 1)
{
return;
}
$return_now = true;
$auth_status = phpbb_auth_username($args['user_id']);
return compact('return_now', 'auth_status');
},
'login_before_submit' => function($args) {
if ($args['config']['phpbb_intr_enabled'] == 1)
{
$args['forget_pass_link'] = rtrim($args['config']['phpbb_intr_link'], '/') . '/ucp.php?mode=sendpassword';
return $args;
}
},
'get_pass_resetpass_link' => function($args) {
if ($args['config']['phpbb_intr_enabled'] == 1)
{
$args['forgetpass_link'] = rtrim($args['config']['phpbb_intr_link'], '/').'/ucp.php?mode=sendpassword';
return $args;
}
},
'register_not_default_sys' => function($args) {
if ($args['config']['phpbb_intr_enabled'] == 1)
{
$args['goto_forum_link'] = rtrim($args['config']['phpbb_intr_link'], '/').'/ucp.php?mode=register';
return $args;
}
},
'no_submit_profile' => function($args) {
if ($args['config']['phpbb_intr_enabled'] == 1)
{
$args['goto_forum_link'] = rtrim($args['config']['phpbb_intr_link'], '/').'/ucp.php';
return $args;
}
},
'end_common' => function($args) {
if ($args['config']['phpbb_intr_enabled'] == 1)
{
$args['config']['user_system'] = 'phpbb';
return $args;
}
},
];
//includes integration functions
include_once __DIR__ . '/phpbb.php';