php 8 + cs fix
This commit is contained in:
parent
297ed98f6d
commit
84d58d8632
9 changed files with 2369 additions and 2362 deletions
|
@ -19,371 +19,335 @@
|
|||
*
|
||||
*/
|
||||
|
||||
include('../serverlib/admin.inc.php');
|
||||
include '../serverlib/admin.inc.php';
|
||||
RequestPrivileges(PRIVILEGES_ADMIN);
|
||||
AdminRequirePrivilege('pluginsadmin');
|
||||
|
||||
if(!isset($_REQUEST['action']))
|
||||
$_REQUEST['action'] = 'plugins';
|
||||
if (!isset($_REQUEST['action'])) {
|
||||
$_REQUEST['action'] = 'plugins';
|
||||
}
|
||||
|
||||
$tabs = array(
|
||||
0 => array(
|
||||
'title' => $lang_admin['plugins'],
|
||||
'relIcon' => 'plugin32.png',
|
||||
'link' => 'plugins.php?',
|
||||
'active' => $_REQUEST['action'] == 'plugins'
|
||||
),
|
||||
1 => array(
|
||||
'title' => $lang_admin['widgets'],
|
||||
'relIcon' => 'wlayout_add32.png',
|
||||
'link' => 'plugins.php?action=widgets&',
|
||||
'active' => $_REQUEST['action'] == 'widgets'
|
||||
),
|
||||
2 => array(
|
||||
'title' => $lang_admin['updates'],
|
||||
'relIcon' => 'updates.png',
|
||||
'link' => 'plugins.php?action=updates&',
|
||||
'active' => $_REQUEST['action'] == 'updates'
|
||||
),
|
||||
3 => array(
|
||||
'title' => $lang_admin['install'],
|
||||
'relIcon' => 'plugin_add.png',
|
||||
'link' => 'plugins.php?action=install&',
|
||||
'active' => $_REQUEST['action'] == 'install'
|
||||
)
|
||||
);
|
||||
$tabs = [
|
||||
0 => [
|
||||
'title' => $lang_admin['plugins'],
|
||||
'relIcon' => 'plugin32.png',
|
||||
'link' => 'plugins.php?',
|
||||
'active' => $_REQUEST['action'] == 'plugins',
|
||||
],
|
||||
1 => [
|
||||
'title' => $lang_admin['widgets'],
|
||||
'relIcon' => 'wlayout_add32.png',
|
||||
'link' => 'plugins.php?action=widgets&',
|
||||
'active' => $_REQUEST['action'] == 'widgets',
|
||||
],
|
||||
2 => [
|
||||
'title' => $lang_admin['updates'],
|
||||
'relIcon' => 'updates.png',
|
||||
'link' => 'plugins.php?action=updates&',
|
||||
'active' => $_REQUEST['action'] == 'updates',
|
||||
],
|
||||
3 => [
|
||||
'title' => $lang_admin['install'],
|
||||
'relIcon' => 'plugin_add.png',
|
||||
'link' => 'plugins.php?action=install&',
|
||||
'active' => $_REQUEST['action'] == 'install',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
/*
|
||||
* plugins/widgets
|
||||
*/
|
||||
if($_REQUEST['action'] == 'plugins'
|
||||
|| $_REQUEST['action'] == 'widgets')
|
||||
{
|
||||
if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'activatePlugin'
|
||||
&& isset($_REQUEST['plugin']) && isset($plugins->_inactivePlugins[$_REQUEST['plugin']]))
|
||||
{
|
||||
$plugins->activatePlugin($_REQUEST['plugin']);
|
||||
$tpl->assign('reloadMenu', true);
|
||||
}
|
||||
else if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'deactivatePlugin'
|
||||
&& isset($_REQUEST['plugin']) && isset($plugins->_plugins[$_REQUEST['plugin']]))
|
||||
{
|
||||
$plugins->deactivatePlugin($_REQUEST['plugin']);
|
||||
$tpl->assign('reloadMenu', true);
|
||||
}
|
||||
else if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'pausePlugin'
|
||||
&& isset($_REQUEST['plugin']) && isset($plugins->_plugins[$_REQUEST['plugin']]))
|
||||
{
|
||||
$plugins->pausePlugin($_REQUEST['plugin']);
|
||||
$tpl->assign('reloadMenu', true);
|
||||
}
|
||||
else if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'unpausePlugin'
|
||||
&& isset($_REQUEST['plugin']) && isset($plugins->_inactivePlugins[$_REQUEST['plugin']]))
|
||||
{
|
||||
$plugins->unpausePlugin($_REQUEST['plugin']);
|
||||
$tpl->assign('reloadMenu', true);
|
||||
}
|
||||
else if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'deletePackage'
|
||||
&& isset($_REQUEST['package']) && strlen($_REQUEST['package']) == 32)
|
||||
{
|
||||
BMPluginPackage::Uninstall($_REQUEST['package']);
|
||||
$tpl->assign('reloadMenu', true);
|
||||
}
|
||||
if ($_REQUEST['action'] == 'plugins'
|
||||
|| $_REQUEST['action'] == 'widgets') {
|
||||
if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'activatePlugin'
|
||||
&& isset($_REQUEST['plugin']) && isset($plugins->_inactivePlugins[$_REQUEST['plugin']])) {
|
||||
$plugins->activatePlugin($_REQUEST['plugin']);
|
||||
$tpl->assign('reloadMenu', true);
|
||||
} elseif (isset($_REQUEST['do']) && $_REQUEST['do'] == 'deactivatePlugin'
|
||||
&& isset($_REQUEST['plugin']) && isset($plugins->_plugins[$_REQUEST['plugin']])) {
|
||||
$plugins->deactivatePlugin($_REQUEST['plugin']);
|
||||
$tpl->assign('reloadMenu', true);
|
||||
} elseif (isset($_REQUEST['do']) && $_REQUEST['do'] == 'pausePlugin'
|
||||
&& isset($_REQUEST['plugin']) && isset($plugins->_plugins[$_REQUEST['plugin']])) {
|
||||
$plugins->pausePlugin($_REQUEST['plugin']);
|
||||
$tpl->assign('reloadMenu', true);
|
||||
} elseif (isset($_REQUEST['do']) && $_REQUEST['do'] == 'unpausePlugin'
|
||||
&& isset($_REQUEST['plugin']) && isset($plugins->_inactivePlugins[$_REQUEST['plugin']])) {
|
||||
$plugins->unpausePlugin($_REQUEST['plugin']);
|
||||
$tpl->assign('reloadMenu', true);
|
||||
} elseif (isset($_REQUEST['do']) && $_REQUEST['do'] == 'deletePackage'
|
||||
&& isset($_REQUEST['package']) && strlen($_REQUEST['package']) == 32) {
|
||||
BMPluginPackage::staticUninstall($_REQUEST['package']);
|
||||
$tpl->assign('reloadMenu', true);
|
||||
}
|
||||
|
||||
$pluginList = array();
|
||||
$pluginList = [];
|
||||
|
||||
// build plugin list
|
||||
foreach($plugins->_plugins as $className=>$pluginInfo)
|
||||
{
|
||||
if(($_REQUEST['action'] == 'plugins' && ($plugins->getParam('type', $className) == BMPLUGIN_DEFAULT
|
||||
|| $plugins->getParam('type', $className) == BMPLUGIN_FILTER))
|
||||
|| ($_REQUEST['action'] == 'widgets' && $plugins->getParam('type', $className) == BMPLUGIN_WIDGET))
|
||||
{
|
||||
if(!isset($pluginList[$pluginInfo['signature']]))
|
||||
$pluginList[$pluginInfo['signature']] = array(
|
||||
'name' => $pluginInfo['packageName'],
|
||||
'plugins' => array()
|
||||
);
|
||||
$pluginList[$pluginInfo['signature']]['plugins'][] = array(
|
||||
'name' => $className,
|
||||
'title' => $plugins->getParam('name', $className),
|
||||
'version' => $plugins->getParam('version', $className),
|
||||
'author' => $plugins->getParam('author', $className),
|
||||
'type' => $pluginTypeTable[$plugins->getParam('type', $className)],
|
||||
'installed' => $plugins->getParam('installed', $className),
|
||||
'paused' => $plugins->getParam('paused', $className)
|
||||
);
|
||||
}
|
||||
}
|
||||
foreach($plugins->_inactivePlugins as $className=>$pluginInfo)
|
||||
{
|
||||
if(($_REQUEST['action'] == 'plugins' && ($pluginInfo['type'] == BMPLUGIN_DEFAULT
|
||||
|| $pluginInfo['type'] == BMPLUGIN_FILTER))
|
||||
|| ($_REQUEST['action'] == 'widgets' && $pluginInfo['type'] == BMPLUGIN_WIDGET))
|
||||
{
|
||||
if(!isset($pluginList[$pluginInfo['signature']]))
|
||||
$pluginList[$pluginInfo['signature']] = array(
|
||||
'name' => $pluginInfo['packageName'],
|
||||
'plugins' => array()
|
||||
);
|
||||
$pluginList[$pluginInfo['signature']]['plugins'][] = array(
|
||||
'name' => $className,
|
||||
'title' => $pluginInfo['name'],
|
||||
'version' => $pluginInfo['version'],
|
||||
'author' => $pluginInfo['author'],
|
||||
'type' => $pluginTypeTable[$pluginInfo['type']],
|
||||
'installed' => $pluginInfo['installed'],
|
||||
'paused' => $pluginInfo['paused']
|
||||
);
|
||||
}
|
||||
}
|
||||
// build plugin list
|
||||
foreach ($plugins->_plugins as $className => $pluginInfo) {
|
||||
if (($_REQUEST['action'] == 'plugins' && ($plugins->getParam('type', $className) == BMPLUGIN_DEFAULT
|
||||
|| $plugins->getParam('type', $className) == BMPLUGIN_FILTER))
|
||||
|| ($_REQUEST['action'] == 'widgets' && $plugins->getParam('type', $className) == BMPLUGIN_WIDGET)) {
|
||||
if (!isset($pluginList[$pluginInfo['signature']])) {
|
||||
$pluginList[$pluginInfo['signature']] = [
|
||||
'name' => $pluginInfo['packageName'],
|
||||
'plugins' => [],
|
||||
];
|
||||
}
|
||||
$pluginList[$pluginInfo['signature']]['plugins'][] = [
|
||||
'name' => $className,
|
||||
'title' => $plugins->getParam('name', $className),
|
||||
'description' => $plugins->getParam('description', $className),
|
||||
'version' => $plugins->getParam('version', $className),
|
||||
'author' => $plugins->getParam('author', $className),
|
||||
'type' => $pluginTypeTable[$plugins->getParam('type', $className)],
|
||||
'installed' => $plugins->getParam('installed', $className),
|
||||
'paused' => $plugins->getParam('paused', $className),
|
||||
];
|
||||
}
|
||||
}
|
||||
foreach ($plugins->_inactivePlugins as $className => $pluginInfo) {
|
||||
if (($_REQUEST['action'] == 'plugins' && ($pluginInfo['type'] == BMPLUGIN_DEFAULT
|
||||
|| $pluginInfo['type'] == BMPLUGIN_FILTER))
|
||||
|| ($_REQUEST['action'] == 'widgets' && $pluginInfo['type'] == BMPLUGIN_WIDGET)) {
|
||||
if (!isset($pluginList[$pluginInfo['signature']])) {
|
||||
$pluginList[$pluginInfo['signature']] = [
|
||||
'name' => $pluginInfo['packageName'],
|
||||
'plugins' => [],
|
||||
];
|
||||
}
|
||||
$pluginList[$pluginInfo['signature']]['plugins'][] = [
|
||||
'name' => $className,
|
||||
'title' => $pluginInfo['name'],
|
||||
'description' => $pluginInfo['description'],
|
||||
'version' => $pluginInfo['version'],
|
||||
'author' => $pluginInfo['author'],
|
||||
'type' => $pluginTypeTable[$pluginInfo['type']],
|
||||
'installed' => $pluginInfo['installed'],
|
||||
'paused' => $pluginInfo['paused'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
function __PluginSort($a, $b)
|
||||
{
|
||||
return(strcasecmp(($a['installed'] ? '0' : '1') . $a['title'], ($b['installed'] ? '0' : '1') . $b['title']));
|
||||
}
|
||||
function __PluginSort($a, $b)
|
||||
{
|
||||
return strcasecmp(($a['installed'] ? '0' : '1').$a['title'], ($b['installed'] ? '0' : '1').$b['title']);
|
||||
}
|
||||
|
||||
function __PluginListSort($a, $b)
|
||||
{
|
||||
return(strcasecmp($a['name'], $b['name']));
|
||||
}
|
||||
function __PluginListSort($a, $b)
|
||||
{
|
||||
return strcasecmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
foreach($pluginList as $key=>$val)
|
||||
uasort($pluginList[$key]['plugins'], '__PluginSort');
|
||||
foreach ($pluginList as $key => $val) {
|
||||
uasort($pluginList[$key]['plugins'], '__PluginSort');
|
||||
}
|
||||
|
||||
uasort($pluginList, '__PluginListSort');
|
||||
uasort($pluginList, '__PluginListSort');
|
||||
|
||||
|
||||
$tpl->assign('action', $_REQUEST['action']);
|
||||
$tpl->assign('plugins', $pluginList);
|
||||
$tpl->assign('page', 'plugins.list.tpl');
|
||||
$tpl->assign('action', $_REQUEST['action']);
|
||||
$tpl->assign('plugins', $pluginList);
|
||||
$tpl->assign('page', 'plugins.list.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* update check page
|
||||
*/
|
||||
else if($_REQUEST['action'] == 'updates')
|
||||
{
|
||||
$pluginList = array();
|
||||
elseif ($_REQUEST['action'] == 'updates') {
|
||||
$pluginList = [];
|
||||
|
||||
// build plugin list
|
||||
foreach($plugins->_plugins as $className=>$pluginInfo)
|
||||
{
|
||||
if(!isset($pluginList[$pluginInfo['signature']]))
|
||||
$pluginList[$pluginInfo['signature']] = array(
|
||||
'name' => $pluginInfo['packageName'],
|
||||
'plugins' => array()
|
||||
);
|
||||
$pluginList[$pluginInfo['signature']]['plugins'][] = array(
|
||||
'name' => $className,
|
||||
'title' => $plugins->getParam('name', $className),
|
||||
'version' => $plugins->getParam('version', $className),
|
||||
'author' => $plugins->getParam('author', $className),
|
||||
'website' => $plugins->getParam('website', $className),
|
||||
'type' => $pluginTypeTable[$plugins->getParam('type', $className)],
|
||||
'installed' => true
|
||||
);
|
||||
}
|
||||
// build plugin list
|
||||
foreach ($plugins->_plugins as $className => $pluginInfo) {
|
||||
if (!isset($pluginList[$pluginInfo['signature']])) {
|
||||
$pluginList[$pluginInfo['signature']] = [
|
||||
'name' => $pluginInfo['packageName'],
|
||||
'plugins' => [],
|
||||
];
|
||||
}
|
||||
$pluginList[$pluginInfo['signature']]['plugins'][] = [
|
||||
'name' => $className,
|
||||
'title' => $plugins->getParam('name', $className),
|
||||
'description' => $plugins->getParam('description', $className),
|
||||
'version' => $plugins->getParam('version', $className),
|
||||
'author' => $plugins->getParam('author', $className),
|
||||
'website' => $plugins->getParam('website', $className),
|
||||
'type' => $pluginTypeTable[$plugins->getParam('type', $className)],
|
||||
'installed' => true,
|
||||
];
|
||||
}
|
||||
|
||||
$tpl->assign('plugins', $pluginList);
|
||||
$tpl->assign('page', 'plugins.updates.tpl');
|
||||
$tpl->assign('plugins', $pluginList);
|
||||
$tpl->assign('page', 'plugins.updates.tpl');
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* perform update check
|
||||
*/
|
||||
else if($_REQUEST['action'] == 'updateCheck'
|
||||
&& isset($_REQUEST['plugin']))
|
||||
{
|
||||
$latestVersion = '';
|
||||
$resultCode = $plugins->callFunction('CheckForUpdates', $_REQUEST['plugin'], false, array(&$latestVersion));
|
||||
elseif ($_REQUEST['action'] == 'updateCheck'
|
||||
&& isset($_REQUEST['plugin'])) {
|
||||
$latestVersion = '';
|
||||
$resultCode = $plugins->callFunction('CheckForUpdates', $_REQUEST['plugin'], false, [&$latestVersion]);
|
||||
|
||||
printf('%s;%d;%s;%s',
|
||||
$_REQUEST['plugin'],
|
||||
$resultCode,
|
||||
$latestVersion,
|
||||
$plugins->getParam('website', $_REQUEST['plugin']));
|
||||
exit();
|
||||
printf('%s;%d;%s;%s',
|
||||
$_REQUEST['plugin'],
|
||||
$resultCode,
|
||||
$latestVersion,
|
||||
$plugins->getParam('website', $_REQUEST['plugin']));
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* install
|
||||
*/
|
||||
else if($_REQUEST['action'] == 'install')
|
||||
{
|
||||
//
|
||||
// form
|
||||
//
|
||||
if(!isset($_REQUEST['do']))
|
||||
{
|
||||
$tpl->assign('page', 'plugins.install.tpl');
|
||||
}
|
||||
elseif ($_REQUEST['action'] == 'install') {
|
||||
//
|
||||
// form
|
||||
//
|
||||
if (!isset($_REQUEST['do'])) {
|
||||
$tpl->assign('page', 'plugins.install.tpl');
|
||||
}
|
||||
|
||||
//
|
||||
// upload
|
||||
//
|
||||
else if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'uploadPlugin')
|
||||
{
|
||||
$formatError = true;
|
||||
//
|
||||
// upload
|
||||
//
|
||||
elseif (isset($_REQUEST['do']) && $_REQUEST['do'] == 'uploadPlugin') {
|
||||
$formatError = true;
|
||||
|
||||
if(isset($_FILES['package']) && $_FILES['package']['error'] == 0
|
||||
&& $_FILES['package']['size'] > 0)
|
||||
{
|
||||
// request temp file
|
||||
$tempFileID = RequestTempFile(0);
|
||||
$tempFileName = TempFileName($tempFileID);
|
||||
if (isset($_FILES['package']) && $_FILES['package']['error'] == 0
|
||||
&& $_FILES['package']['size'] > 0) {
|
||||
// request temp file
|
||||
$tempFileID = RequestTempFile(0);
|
||||
$tempFileName = TempFileName($tempFileID);
|
||||
|
||||
// move file
|
||||
$fileName = $_FILES['package']['name'];
|
||||
move_uploaded_file($_FILES['package']['tmp_name'], $tempFileName);
|
||||
// move file
|
||||
$fileName = $_FILES['package']['name'];
|
||||
move_uploaded_file($_FILES['package']['tmp_name'], $tempFileName);
|
||||
|
||||
// open file
|
||||
$package = _new('BMPluginPackage', array($fp = fopen($tempFileName, 'rb')));
|
||||
if($package->ParseFile())
|
||||
{
|
||||
$meta = $package->metaInfo;
|
||||
// open file
|
||||
$package = _new('BMPluginPackage', [$fp = fopen($tempFileName, 'rb')]);
|
||||
if ($package->ParseFile()) {
|
||||
$meta = $package->metaInfo;
|
||||
|
||||
foreach($meta as $key=>$val)
|
||||
if(is_string($val))
|
||||
$meta[$key] = CharsetDecode($val, FALLBACK_CHARSET);
|
||||
foreach ($meta as $key => $val) {
|
||||
if (is_string($val)) {
|
||||
$meta[$key] = CharsetDecode($val, FALLBACK_CHARSET);
|
||||
}
|
||||
}
|
||||
|
||||
$formatError = false;
|
||||
$tpl->assign('id', $tempFileID);
|
||||
$tpl->assign('meta', $meta);
|
||||
$tpl->assign('signature', $package->signature);
|
||||
$tpl->assign('versionsMatch', $package->metaInfo['for_b1gmail'] == B1GMAIL_VERSION);
|
||||
$tpl->assign('b1gmailVersion', B1GMAIL_VERSION);
|
||||
$tpl->assign('page', 'plugin.install.info.tpl');
|
||||
}
|
||||
$formatError = false;
|
||||
$tpl->assign('id', $tempFileID);
|
||||
$tpl->assign('meta', $meta);
|
||||
$tpl->assign('signature', $package->signature);
|
||||
$tpl->assign('versionsMatch', $package->metaInfo['for_b1gmail'] == B1GMAIL_VERSION);
|
||||
$tpl->assign('b1gmailVersion', B1GMAIL_VERSION);
|
||||
$tpl->assign('page', 'plugin.install.info.tpl');
|
||||
}
|
||||
|
||||
// close file
|
||||
fclose($fp);
|
||||
}
|
||||
// close file
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
// invalid file => message
|
||||
if($formatError)
|
||||
{
|
||||
$tpl->assign('msgTitle', $lang_admin['install']);
|
||||
$tpl->assign('msgText', $lang_admin['plugin_formaterr']);
|
||||
$tpl->assign('msgIcon', 'error32');
|
||||
$tpl->assign('backLink', 'plugins.php?action=install&');
|
||||
$tpl->assign('page', 'msg.tpl');
|
||||
}
|
||||
}
|
||||
// invalid file => message
|
||||
if ($formatError) {
|
||||
$tpl->assign('msgTitle', $lang_admin['install']);
|
||||
$tpl->assign('msgText', $lang_admin['plugin_formaterr']);
|
||||
$tpl->assign('msgIcon', 'error32');
|
||||
$tpl->assign('backLink', 'plugins.php?action=install&');
|
||||
$tpl->assign('page', 'msg.tpl');
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// check signature
|
||||
//
|
||||
else if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'checkSignature'
|
||||
&& isset($_REQUEST['signature']) && strlen($_REQUEST['signature']) == 32)
|
||||
{
|
||||
$result = BMPluginPackage::VerifySignature($_REQUEST['signature']);
|
||||
//
|
||||
// check signature
|
||||
//
|
||||
elseif (isset($_REQUEST['do']) && $_REQUEST['do'] == 'checkSignature'
|
||||
&& isset($_REQUEST['signature']) && strlen($_REQUEST['signature']) == 32) {
|
||||
$result = BMPluginPackage::VerifySignature($_REQUEST['signature']);
|
||||
|
||||
if($result === false)
|
||||
{
|
||||
$tpl->assign('icon', 'error32');
|
||||
$tpl->assign('title', $lang_admin['sigfailed']);
|
||||
$tpl->assign('text', $lang_admin['sigfailed_desc']);
|
||||
}
|
||||
else if($result == SIGNATURE_OFFICIAL)
|
||||
{
|
||||
$tpl->assign('icon', 'sig_ok');
|
||||
$tpl->assign('title', $lang_admin['sigofficial']);
|
||||
$tpl->assign('text', $lang_admin['sigofficial_desc']);
|
||||
}
|
||||
else if($result == SIGNATURE_VERIFIED)
|
||||
{
|
||||
$tpl->assign('icon', 'sig');
|
||||
$tpl->assign('title', $lang_admin['sigver']);
|
||||
$tpl->assign('text', $lang_admin['sigver_desc']);
|
||||
}
|
||||
else if($result == SIGNATURE_UNKNOWN)
|
||||
{
|
||||
$tpl->assign('icon', 'sig_unknown');
|
||||
$tpl->assign('title', $lang_admin['sigunknown']);
|
||||
$tpl->assign('text', $lang_admin['sigunknown_desc']);
|
||||
}
|
||||
else if($result == SIGNATURE_MALICIOUS)
|
||||
{
|
||||
$tpl->assign('icon', 'sig_mal');
|
||||
$tpl->assign('title', $lang_admin['sigmal']);
|
||||
$tpl->assign('text', $lang_admin['sigmal_desc']);
|
||||
}
|
||||
if ($result === false) {
|
||||
$tpl->assign('icon', 'error32');
|
||||
$tpl->assign('title', $lang_admin['sigfailed']);
|
||||
$tpl->assign('text', $lang_admin['sigfailed_desc']);
|
||||
} elseif ($result == SIGNATURE_OFFICIAL) {
|
||||
$tpl->assign('icon', 'sig_ok');
|
||||
$tpl->assign('title', $lang_admin['sigofficial']);
|
||||
$tpl->assign('text', $lang_admin['sigofficial_desc']);
|
||||
} elseif ($result == SIGNATURE_VERIFIED) {
|
||||
$tpl->assign('icon', 'sig');
|
||||
$tpl->assign('title', $lang_admin['sigver']);
|
||||
$tpl->assign('text', $lang_admin['sigver_desc']);
|
||||
} elseif ($result == SIGNATURE_UNKNOWN) {
|
||||
$tpl->assign('icon', 'sig_unknown');
|
||||
$tpl->assign('title', $lang_admin['sigunknown']);
|
||||
$tpl->assign('text', $lang_admin['sigunknown_desc']);
|
||||
} elseif ($result == SIGNATURE_MALICIOUS) {
|
||||
$tpl->assign('icon', 'sig_mal');
|
||||
$tpl->assign('title', $lang_admin['sigmal']);
|
||||
$tpl->assign('text', $lang_admin['sigmal_desc']);
|
||||
}
|
||||
|
||||
$tpl->display('plugin.install.signature.tpl');
|
||||
exit();
|
||||
}
|
||||
$tpl->display('plugin.install.signature.tpl');
|
||||
exit();
|
||||
}
|
||||
|
||||
//
|
||||
// install
|
||||
//
|
||||
else if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'installPlugin'
|
||||
&& isset($_REQUEST['id']) && ValidTempFile(0, (int)$_REQUEST['id']))
|
||||
{
|
||||
if(isset($_REQUEST['step']))
|
||||
$step = max(1, min(2, (int)$_REQUEST['step']));
|
||||
else
|
||||
$step = 1;
|
||||
//
|
||||
// install
|
||||
//
|
||||
elseif (isset($_REQUEST['do']) && $_REQUEST['do'] == 'installPlugin'
|
||||
&& isset($_REQUEST['id']) && ValidTempFile(0, (int) $_REQUEST['id'])) {
|
||||
if (isset($_REQUEST['step'])) {
|
||||
$step = max(1, min(2, (int) $_REQUEST['step']));
|
||||
} else {
|
||||
$step = 1;
|
||||
}
|
||||
|
||||
$id = (int)$_REQUEST['id'];
|
||||
$tempFileName = TempFileName($id);
|
||||
$id = (int) $_REQUEST['id'];
|
||||
$tempFileName = TempFileName($id);
|
||||
|
||||
// open file
|
||||
$package = _new('BMPluginPackage', array($fp = fopen($tempFileName, 'rb')));
|
||||
if($package->ParseFile())
|
||||
{
|
||||
if($step == 1)
|
||||
{
|
||||
if($package->InstallStep1())
|
||||
{
|
||||
$url = sprintf('plugins.php?action=install&do=installPlugin&id=%d&step=2&sid=%s',
|
||||
$id,
|
||||
session_id());
|
||||
header('Location: ' . $url);
|
||||
fclose($fp);
|
||||
exit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$tpl->assign('msgTitle', $lang_admin['install']);
|
||||
$tpl->assign('msgText', $lang_admin['plugin_insterr']);
|
||||
$tpl->assign('msgIcon', 'error32');
|
||||
$tpl->assign('backLink', 'plugins.php?action=install&');
|
||||
$tpl->assign('page', 'msg.tpl');
|
||||
fclose($fp);
|
||||
ReleaseTempFile(0, $id);
|
||||
}
|
||||
}
|
||||
// open file
|
||||
$package = _new('BMPluginPackage', [$fp = fopen($tempFileName, 'rb')]);
|
||||
if ($package->ParseFile()) {
|
||||
if ($step == 1) {
|
||||
if ($package->InstallStep1()) {
|
||||
$url = sprintf('plugins.php?action=install&do=installPlugin&id=%d&step=2&sid=%s',
|
||||
$id,
|
||||
session_id());
|
||||
header('Location: '.$url);
|
||||
fclose($fp);
|
||||
exit();
|
||||
} else {
|
||||
$tpl->assign('msgTitle', $lang_admin['install']);
|
||||
$tpl->assign('msgText', $lang_admin['plugin_insterr']);
|
||||
$tpl->assign('msgIcon', 'error32');
|
||||
$tpl->assign('backLink', 'plugins.php?action=install&');
|
||||
$tpl->assign('page', 'msg.tpl');
|
||||
fclose($fp);
|
||||
ReleaseTempFile(0, $id);
|
||||
}
|
||||
} elseif ($step == 2) {
|
||||
if ($package->InstallStep2()) {
|
||||
$tpl->assign('reloadMenu', true);
|
||||
$tpl->assign('msgTitle', $lang_admin['install']);
|
||||
$tpl->assign('msgText', $lang_admin['plugin_installed']);
|
||||
$tpl->assign('msgIcon', 'info32');
|
||||
$tpl->assign('backLink', 'plugins.php?');
|
||||
$tpl->assign('page', 'msg.tpl');
|
||||
} else {
|
||||
$tpl->assign('msgTitle', $lang_admin['install']);
|
||||
$tpl->assign('msgText', $lang_admin['plugin_insterr']);
|
||||
$tpl->assign('msgIcon', 'error32');
|
||||
$tpl->assign('backLink', 'plugins.php?action=install&');
|
||||
$tpl->assign('page', 'msg.tpl');
|
||||
}
|
||||
|
||||
else if($step == 2)
|
||||
{
|
||||
if($package->InstallStep2())
|
||||
{
|
||||
$tpl->assign('reloadMenu', true);
|
||||
$tpl->assign('msgTitle', $lang_admin['install']);
|
||||
$tpl->assign('msgText', $lang_admin['plugin_installed']);
|
||||
$tpl->assign('msgIcon', 'info32');
|
||||
$tpl->assign('backLink', 'plugins.php?');
|
||||
$tpl->assign('page', 'msg.tpl');
|
||||
}
|
||||
else
|
||||
{
|
||||
$tpl->assign('msgTitle', $lang_admin['install']);
|
||||
$tpl->assign('msgText', $lang_admin['plugin_insterr']);
|
||||
$tpl->assign('msgIcon', 'error32');
|
||||
$tpl->assign('backLink', 'plugins.php?action=install&');
|
||||
$tpl->assign('page', 'msg.tpl');
|
||||
}
|
||||
|
||||
// close and release file
|
||||
fclose($fp);
|
||||
ReleaseTempFile(0, $id);
|
||||
}
|
||||
}
|
||||
}
|
||||
// close and release file
|
||||
fclose($fp);
|
||||
ReleaseTempFile(0, $id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tpl->assign('tabs', $tabs);
|
||||
$tpl->assign('title', $lang_admin['plugins'] . ' » ' . $lang_admin['plugins']);
|
||||
$tpl->assign('title', $lang_admin['plugins'].' » '.$lang_admin['plugins']);
|
||||
$tpl->display('page.tpl');
|
||||
?>
|
|
@ -20,301 +20,289 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* News plugin
|
||||
*
|
||||
* News plugin.
|
||||
*/
|
||||
class NewsPlugin extends BMPlugin
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
// plugin info
|
||||
$this->type = BMPLUGIN_DEFAULT;
|
||||
$this->name = 'News';
|
||||
$this->author = 'b1gMail Project';
|
||||
$this->mail = 'info@b1gmail.org';
|
||||
$this->version = '1.7';
|
||||
$this->update_url = 'https://service.b1gmail.org/plugin_updates/';
|
||||
$this->website = 'https://www.b1gmail.org/';
|
||||
public function __construct()
|
||||
{
|
||||
// plugin info
|
||||
$this->type = BMPLUGIN_DEFAULT;
|
||||
$this->name = 'News';
|
||||
$this->author = 'b1gMail Project';
|
||||
$this->mail = 'info@b1gmail.org';
|
||||
$this->version = '1.7';
|
||||
$this->update_url = 'https://service.b1gmail.org/plugin_updates/';
|
||||
$this->website = 'https://www.b1gmail.org/';
|
||||
|
||||
$this->admin_pages = true;
|
||||
$this->admin_page_title = 'News';
|
||||
$this->admin_page_icon = 'news_icon.png';
|
||||
}
|
||||
$this->admin_pages = true;
|
||||
$this->admin_page_title = 'News';
|
||||
$this->admin_page_icon = 'news_icon.png';
|
||||
}
|
||||
|
||||
function OnReadLang(&$lang_user, &$lang_client, &$lang_custom, &$lang_admin, $lang)
|
||||
{
|
||||
if($lang == 'deutsch')
|
||||
{
|
||||
$lang_admin['news_news'] = 'News';
|
||||
$lang_admin['news_addnews'] = 'News hinzufügen';
|
||||
public function OnReadLang(&$lang_user, &$lang_client, &$lang_custom, &$lang_admin, $lang)
|
||||
{
|
||||
if ($lang == 'deutsch') {
|
||||
$lang_admin['news_news'] = 'News';
|
||||
$lang_admin['news_addnews'] = 'News hinzufügen';
|
||||
|
||||
$lang_user['news_news'] = 'News';
|
||||
$lang_user['news_nonews'] = 'Es konnten keine News gefunden werden.';
|
||||
$lang_user['news_text'] = 'Hier finden Sie aktuelle Informationen und Ankündigungen rund um unserem Dienst.';
|
||||
}
|
||||
else
|
||||
{
|
||||
$lang_admin['news_news'] = 'News';
|
||||
$lang_admin['news_addnews'] = 'Add news';
|
||||
$lang_user['news_news'] = 'News';
|
||||
$lang_user['news_nonews'] = 'Es konnten keine News gefunden werden.';
|
||||
$lang_user['news_text'] = 'Hier finden Sie aktuelle Informationen und Ankündigungen rund um unserem Dienst.';
|
||||
} else {
|
||||
$lang_admin['news_news'] = 'News';
|
||||
$lang_admin['news_addnews'] = 'Add news';
|
||||
|
||||
$lang_user['news_news'] = 'News';
|
||||
$lang_user['news_nonews'] = 'Could not find any news.';
|
||||
$lang_user['news_text'] = 'Here you can find current information and announcements regarding our service.';
|
||||
}
|
||||
}
|
||||
$lang_user['news_news'] = 'News';
|
||||
$lang_user['news_nonews'] = 'Could not find any news.';
|
||||
$lang_user['news_text'] = 'Here you can find current information and announcements regarding our service.';
|
||||
}
|
||||
}
|
||||
|
||||
function Install()
|
||||
{
|
||||
global $db;
|
||||
public function Install()
|
||||
{
|
||||
global $db;
|
||||
|
||||
// db struct
|
||||
$databaseStructure =
|
||||
'YToxOntzOjk6ImJtNjBfbmV3cyI7YToyOntzOjY6ImZpZWxkcyI7YTo2OntpOjA7YTo2OntpOjA'
|
||||
. '7czo2OiJuZXdzaWQiO2k6MTtzOjc6ImludCgxMSkiO2k6MjtzOjI6Ik5PIjtpOjM7czozOiJQUk'
|
||||
. 'kiO2k6NDtOO2k6NTtzOjE0OiJhdXRvX2luY3JlbWVudCI7fWk6MTthOjY6e2k6MDtzOjQ6ImRhd'
|
||||
. 'GUiO2k6MTtzOjc6ImludCgxMSkiO2k6MjtzOjI6Ik5PIjtpOjM7czowOiIiO2k6NDtzOjE6IjAi'
|
||||
. 'O2k6NTtzOjA6IiI7fWk6MjthOjY6e2k6MDtzOjU6InRpdGxlIjtpOjE7czoxMjoidmFyY2hhcig'
|
||||
. 'xMjgpIjtpOjI7czoyOiJOTyI7aTozO3M6MDoiIjtpOjQ7czowOiIiO2k6NTtzOjA6IiI7fWk6Mz'
|
||||
. 'thOjY6e2k6MDtzOjQ6InRleHQiO2k6MTtzOjQ6InRleHQiO2k6MjtzOjI6Ik5PIjtpOjM7czowO'
|
||||
. 'iIiO2k6NDtzOjA6IiI7aTo1O3M6MDoiIjt9aTo0O2E6Njp7aTowO3M6ODoibG9nZ2VkaW4iO2k6'
|
||||
. 'MTtzOjIzOiJlbnVtKCdsaScsJ25saScsJ2JvdGgnKSI7aToyO3M6MjoiTk8iO2k6MztzOjA6IiI'
|
||||
. '7aTo0O3M6NDoiYm90aCI7aTo1O3M6MDoiIjt9aTo1O2E6Njp7aTowO3M6NjoiZ3JvdXBzIjtpOj'
|
||||
. 'E7czoxMToidmFyY2hhcig2NCkiO2k6MjtzOjI6Ik5PIjtpOjM7czowOiIiO2k6NDtzOjE6IioiO'
|
||||
. '2k6NTtzOjA6IiI7fX1zOjc6ImluZGV4ZXMiO2E6MTp7czo3OiJQUklNQVJZIjthOjE6e2k6MDtz'
|
||||
. 'OjY6Im5ld3NpZCI7fX19fQ==';
|
||||
$databaseStructure = unserialize(base64_decode($databaseStructure));
|
||||
// db struct
|
||||
$databaseStructure =
|
||||
'YToxOntzOjk6ImJtNjBfbmV3cyI7YToyOntzOjY6ImZpZWxkcyI7YTo2OntpOjA7YTo2OntpOjA'
|
||||
.'7czo2OiJuZXdzaWQiO2k6MTtzOjc6ImludCgxMSkiO2k6MjtzOjI6Ik5PIjtpOjM7czozOiJQUk'
|
||||
.'kiO2k6NDtOO2k6NTtzOjE0OiJhdXRvX2luY3JlbWVudCI7fWk6MTthOjY6e2k6MDtzOjQ6ImRhd'
|
||||
.'GUiO2k6MTtzOjc6ImludCgxMSkiO2k6MjtzOjI6Ik5PIjtpOjM7czowOiIiO2k6NDtzOjE6IjAi'
|
||||
.'O2k6NTtzOjA6IiI7fWk6MjthOjY6e2k6MDtzOjU6InRpdGxlIjtpOjE7czoxMjoidmFyY2hhcig'
|
||||
.'xMjgpIjtpOjI7czoyOiJOTyI7aTozO3M6MDoiIjtpOjQ7czowOiIiO2k6NTtzOjA6IiI7fWk6Mz'
|
||||
.'thOjY6e2k6MDtzOjQ6InRleHQiO2k6MTtzOjQ6InRleHQiO2k6MjtzOjI6Ik5PIjtpOjM7czowO'
|
||||
.'iIiO2k6NDtzOjA6IiI7aTo1O3M6MDoiIjt9aTo0O2E6Njp7aTowO3M6ODoibG9nZ2VkaW4iO2k6'
|
||||
.'MTtzOjIzOiJlbnVtKCdsaScsJ25saScsJ2JvdGgnKSI7aToyO3M6MjoiTk8iO2k6MztzOjA6IiI'
|
||||
.'7aTo0O3M6NDoiYm90aCI7aTo1O3M6MDoiIjt9aTo1O2E6Njp7aTowO3M6NjoiZ3JvdXBzIjtpOj'
|
||||
.'E7czoxMToidmFyY2hhcig2NCkiO2k6MjtzOjI6Ik5PIjtpOjM7czowOiIiO2k6NDtzOjE6IioiO'
|
||||
.'2k6NTtzOjA6IiI7fX1zOjc6ImluZGV4ZXMiO2E6MTp7czo3OiJQUklNQVJZIjthOjE6e2k6MDtz'
|
||||
.'OjY6Im5ld3NpZCI7fX19fQ==';
|
||||
$databaseStructure = unserialize(base64_decode($databaseStructure));
|
||||
|
||||
// sync struct
|
||||
SyncDBStruct($databaseStructure);
|
||||
// sync struct
|
||||
SyncDBStruct($databaseStructure);
|
||||
|
||||
// log
|
||||
PutLog(sprintf('%s v%s installed',
|
||||
$this->name,
|
||||
$this->version),
|
||||
PRIO_PLUGIN,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
// log
|
||||
PutLog(sprintf('%s v%s installed',
|
||||
$this->name,
|
||||
$this->version),
|
||||
PRIO_PLUGIN,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
|
||||
return(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function AdminHandler()
|
||||
{
|
||||
global $tpl, $bm_prefs, $lang_admin, $db;
|
||||
public function AdminHandler()
|
||||
{
|
||||
global $tpl, $bm_prefs, $lang_admin, $db;
|
||||
|
||||
if(!isset($_REQUEST['action']))
|
||||
$_REQUEST['action'] = 'news';
|
||||
if (!isset($_REQUEST['action'])) {
|
||||
$_REQUEST['action'] = 'news';
|
||||
}
|
||||
|
||||
$tabs = array(
|
||||
0 => array(
|
||||
'title' => $lang_admin['news_news'],
|
||||
'link' => $this->_adminLink() . '&',
|
||||
'icon' => '../plugins/templates/images/news_add.png',
|
||||
'active' => $_REQUEST['action'] == 'news'
|
||||
)
|
||||
);
|
||||
$tabs = [
|
||||
0 => [
|
||||
'title' => $lang_admin['news_news'],
|
||||
'link' => $this->_adminLink().'&',
|
||||
'icon' => '../plugins/templates/images/news_add.png',
|
||||
'active' => $_REQUEST['action'] == 'news',
|
||||
],
|
||||
];
|
||||
|
||||
$tpl->assign('tabs', $tabs);
|
||||
$tpl->assign('pageURL', $this->_adminLink());
|
||||
$tpl->assign('tabs', $tabs);
|
||||
$tpl->assign('pageURL', $this->_adminLink());
|
||||
|
||||
if($_REQUEST['action'] == 'news')
|
||||
{
|
||||
//
|
||||
// overview (+ add, delete)
|
||||
//
|
||||
if(!isset($_REQUEST['do']))
|
||||
{
|
||||
if(isset($_REQUEST['add']))
|
||||
{
|
||||
if(isset($_REQUEST['all_groups']))
|
||||
$groups = '*';
|
||||
else
|
||||
$groups = implode(',', is_array($_REQUEST['groups']) ? $_REQUEST['groups'] : array());
|
||||
$db->Query('INSERT INTO {pre}news(`title`,`date`,`loggedin`,`groups`,`text`) VALUES(?,?,?,?,?)',
|
||||
$_REQUEST['title'],
|
||||
time(),
|
||||
$_REQUEST['loggedin'],
|
||||
$groups,
|
||||
$_REQUEST['text']);
|
||||
}
|
||||
if ($_REQUEST['action'] == 'news') {
|
||||
//
|
||||
// overview (+ add, delete)
|
||||
//
|
||||
if (!isset($_REQUEST['do'])) {
|
||||
if (isset($_REQUEST['add'])) {
|
||||
if (isset($_REQUEST['all_groups'])) {
|
||||
$groups = '*';
|
||||
} else {
|
||||
$groups = implode(',', is_array($_REQUEST['groups']) ? $_REQUEST['groups'] : []);
|
||||
}
|
||||
$db->Query('INSERT INTO {pre}news(`title`,`date`,`loggedin`,`groups`,`text`) VALUES(?,?,?,?,?)',
|
||||
$_REQUEST['title'],
|
||||
time(),
|
||||
$_REQUEST['loggedin'],
|
||||
$groups,
|
||||
$_REQUEST['text']);
|
||||
} elseif (isset($_REQUEST['delete'])) {
|
||||
$db->Query('DELETE FROM {pre}news WHERE `newsid`=?',
|
||||
(int) $_REQUEST['delete']);
|
||||
}
|
||||
|
||||
else if(isset($_REQUEST['delete']))
|
||||
{
|
||||
$db->Query('DELETE FROM {pre}news WHERE `newsid`=?',
|
||||
(int)$_REQUEST['delete']);
|
||||
}
|
||||
$news = [];
|
||||
$res = $db->Query('SELECT `newsid`,`title`,`date`,`loggedin` FROM {pre}news ORDER BY `newsid` DESC');
|
||||
while ($row = $res->FetchArray(MYSQLI_ASSOC)) {
|
||||
$news[$row['newsid']] = $row;
|
||||
}
|
||||
$res->Free();
|
||||
|
||||
$news = array();
|
||||
$res = $db->Query('SELECT `newsid`,`title`,`date`,`loggedin` FROM {pre}news ORDER BY `newsid` DESC');
|
||||
while($row = $res->FetchArray(MYSQLI_ASSOC))
|
||||
$news[$row['newsid']] = $row;
|
||||
$res->Free();
|
||||
$tpl->assign('usertpldir', B1GMAIL_REL.'templates/'.$bm_prefs['template'].'/');
|
||||
$tpl->assign('groups', BMGroup::GetSimpleGroupList());
|
||||
$tpl->assign('news', $news);
|
||||
$tpl->assign('page', $this->_templatePath('news.admin.tpl'));
|
||||
}
|
||||
|
||||
$tpl->assign('usertpldir', B1GMAIL_REL . 'templates/' . $bm_prefs['template'] . '/');
|
||||
$tpl->assign('groups', BMGroup::GetSimpleGroupList());
|
||||
$tpl->assign('news', $news);
|
||||
$tpl->assign('page', $this->_templatePath('news.admin.tpl'));
|
||||
}
|
||||
//
|
||||
// edit
|
||||
//
|
||||
elseif ($_REQUEST['do'] == 'edit'
|
||||
&& isset($_REQUEST['id'])) {
|
||||
if (isset($_REQUEST['save'])) {
|
||||
if (isset($_REQUEST['all_groups'])) {
|
||||
$groups = '*';
|
||||
} else {
|
||||
$groups = implode(',', is_array($_REQUEST['groups']) ? $_REQUEST['groups'] : []);
|
||||
}
|
||||
$db->Query('UPDATE {pre}news SET `title`=?,`loggedin`=?,`groups`=?,`text`=? WHERE `newsid`=?',
|
||||
$_REQUEST['title'],
|
||||
$_REQUEST['loggedin'],
|
||||
$groups,
|
||||
$_REQUEST['text'],
|
||||
(int) $_REQUEST['id']);
|
||||
header('Location: '.$this->_adminLink().'&sid='.session_id());
|
||||
exit();
|
||||
}
|
||||
|
||||
//
|
||||
// edit
|
||||
//
|
||||
else if($_REQUEST['do'] == 'edit'
|
||||
&& isset($_REQUEST['id']))
|
||||
{
|
||||
if(isset($_REQUEST['save']))
|
||||
{
|
||||
if(isset($_REQUEST['all_groups']))
|
||||
$groups = '*';
|
||||
else
|
||||
$groups = implode(',', is_array($_REQUEST['groups']) ? $_REQUEST['groups'] : array());
|
||||
$db->Query('UPDATE {pre}news SET `title`=?,`loggedin`=?,`groups`=?,`text`=? WHERE `newsid`=?',
|
||||
$_REQUEST['title'],
|
||||
$_REQUEST['loggedin'],
|
||||
$groups,
|
||||
$_REQUEST['text'],
|
||||
(int)$_REQUEST['id']);
|
||||
header('Location: ' . $this->_adminLink() . '&sid=' . session_id());
|
||||
exit();
|
||||
}
|
||||
// fetch news
|
||||
$news = [];
|
||||
$res = $db->Query('SELECT `newsid`,`title`,`text`,`loggedin`,`groups` FROM {pre}news WHERE `newsid`=?',
|
||||
(int) $_REQUEST['id']);
|
||||
if ($res->RowCount() != 1) {
|
||||
exit();
|
||||
}
|
||||
$news = $res->FetchArray();
|
||||
$res->Free();
|
||||
|
||||
// fetch news
|
||||
$news = array();
|
||||
$res = $db->Query('SELECT `newsid`,`title`,`text`,`loggedin`,`groups` FROM {pre}news WHERE `newsid`=?',
|
||||
(int)$_REQUEST['id']);
|
||||
if($res->RowCount() != 1)
|
||||
exit();
|
||||
$news = $res->FetchArray();;
|
||||
$res->Free();
|
||||
// process groups
|
||||
$groups = BMGroup::GetSimpleGroupList();
|
||||
if ($news['groups'] != '*') {
|
||||
$newsGroups = explode(',', $news['groups']);
|
||||
|
||||
// process groups
|
||||
$groups = BMGroup::GetSimpleGroupList();
|
||||
if($news['groups'] != '*')
|
||||
{
|
||||
$newsGroups = explode(',', $news['groups']);
|
||||
foreach ($groups as $key => $val) {
|
||||
if (in_array($val['id'], $newsGroups)) {
|
||||
$groups[$key]['checked'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($groups as $key=>$val)
|
||||
{
|
||||
if(in_array($val['id'], $newsGroups))
|
||||
$groups[$key]['checked'] = true;
|
||||
}
|
||||
}
|
||||
$tpl->assign('usertpldir', B1GMAIL_REL.'templates/'.$bm_prefs['template'].'/');
|
||||
$tpl->assign('groups', $groups);
|
||||
$tpl->assign('news', $news);
|
||||
$tpl->assign('page', $this->_templatePath('news.admin.edit.tpl'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tpl->assign('usertpldir', B1GMAIL_REL . 'templates/' . $bm_prefs['template'] . '/');
|
||||
$tpl->assign('groups', $groups);
|
||||
$tpl->assign('news', $news);
|
||||
$tpl->assign('page', $this->_templatePath('news.admin.edit.tpl'));
|
||||
}
|
||||
}
|
||||
}
|
||||
public function FileHandler($file, $action)
|
||||
{
|
||||
global $tpl, $groupRow;
|
||||
|
||||
function FileHandler($file, $action)
|
||||
{
|
||||
global $tpl, $groupRow;
|
||||
if ($file == 'index.php' && $action == 'newsPlugin') {
|
||||
$news = $this->_getNews(false);
|
||||
|
||||
if($file == 'index.php' && $action == 'newsPlugin')
|
||||
{
|
||||
$news = $this->_getNews(false);
|
||||
$tpl->assign('news', $news);
|
||||
$tpl->assign('page', $this->_templatePath('news.notloggedin.tpl'));
|
||||
$tpl->display('nli/index.tpl');
|
||||
|
||||
$tpl->assign('news', $news);
|
||||
$tpl->assign('page', $this->_templatePath('news.notloggedin.tpl'));
|
||||
$tpl->display('nli/index.tpl');
|
||||
exit();
|
||||
} elseif ($file == 'start.php' && $action == 'newsPlugin') {
|
||||
if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'showNews' && isset($_REQUEST['id'])) {
|
||||
$news = $this->_getNews(true, $groupRow['id']);
|
||||
|
||||
exit();
|
||||
}
|
||||
else if($file == 'start.php' && $action == 'newsPlugin')
|
||||
{
|
||||
if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'showNews' && isset($_REQUEST['id']))
|
||||
{
|
||||
$news = $this->_getNews(true, $groupRow['id']);
|
||||
if (isset($news[$_REQUEST['id']])) {
|
||||
$tpl->assign('news', $news[$_REQUEST['id']]);
|
||||
$tpl->display($this->_templatePath('news.show.tpl'));
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($news[$_REQUEST['id']]))
|
||||
{
|
||||
$tpl->assign('news', $news[$_REQUEST['id']]);
|
||||
$tpl->display($this->_templatePath('news.show.tpl'));
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public function getUserPages($loggedin)
|
||||
{
|
||||
global $lang_user;
|
||||
|
||||
function getUserPages($loggedin)
|
||||
{
|
||||
global $lang_user;
|
||||
if ($loggedin) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if($loggedin)
|
||||
return(array());
|
||||
if (count($this->_getNews(false)) < 1) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if(count($this->_getNews(false)) < 1)
|
||||
return(array());
|
||||
return [
|
||||
'news' => [
|
||||
'text' => $lang_user['news_news'],
|
||||
'link' => 'index.php?action=newsPlugin',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
return(array(
|
||||
'news' => array(
|
||||
'text' => $lang_user['news_news'],
|
||||
'link' => 'index.php?action=newsPlugin'
|
||||
)
|
||||
));
|
||||
}
|
||||
public function _getNews($loggedin, $groupID = 0, $sortField = 'date', $sortDirection = 'DESC')
|
||||
{
|
||||
global $db;
|
||||
|
||||
function _getNews($loggedin, $groupID = 0, $sortField = 'date', $sortDirection = 'DESC')
|
||||
{
|
||||
global $db;
|
||||
$result = [];
|
||||
$res = $db->Query('SELECT `newsid`,`date`,`title`,`text` FROM {pre}news WHERE (`loggedin`=? OR `loggedin`=?) AND (`loggedin`=? OR `groups`=? OR `groups`=? OR `groups` LIKE ? OR `groups` LIKE ? OR `groups` LIKE ?) ORDER BY `'.$sortField.'` '.$sortDirection,
|
||||
$loggedin ? 'li' : 'nli',
|
||||
'both',
|
||||
'nli',
|
||||
'*',
|
||||
$groupID,
|
||||
$groupID.',%',
|
||||
'%,'.$groupID.',%',
|
||||
'%,'.$groupID);
|
||||
while ($row = $res->FetchArray(MYSQLI_ASSOC)) {
|
||||
$result[$row['newsid']] = $row;
|
||||
}
|
||||
$res->Free();
|
||||
|
||||
$result = array();
|
||||
$res = $db->Query('SELECT `newsid`,`date`,`title`,`text` FROM {pre}news WHERE (`loggedin`=? OR `loggedin`=?) AND (`loggedin`=? OR `groups`=? OR `groups`=? OR `groups` LIKE ? OR `groups` LIKE ? OR `groups` LIKE ?) ORDER BY `' . $sortField . '` ' . $sortDirection,
|
||||
$loggedin ? 'li' : 'nli',
|
||||
'both',
|
||||
'nli',
|
||||
'*',
|
||||
$groupID,
|
||||
$groupID . ',%',
|
||||
'%,' . $groupID . ',%',
|
||||
'%,' . $groupID);
|
||||
while($row = $res->FetchArray(MYSQLI_ASSOC))
|
||||
{
|
||||
$result[$row['newsid']] = $row;
|
||||
}
|
||||
$res->Free();
|
||||
|
||||
return($result);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* News widget
|
||||
*
|
||||
* News widget.
|
||||
*/
|
||||
class NewsWidget extends BMPlugin
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
// plugin info
|
||||
$this->type = BMPLUGIN_WIDGET;
|
||||
$this->name = 'News widget';
|
||||
$this->author = 'b1gMail Project';
|
||||
$this->mail = 'info@b1gmail.org';
|
||||
$this->version = '1.7';
|
||||
$this->widgetTemplate = 'widget.news.tpl';
|
||||
$this->widgetTitle = 'News';
|
||||
$this->update_url = 'https://service.b1gmail.org/plugin_updates/';
|
||||
$this->website = 'https://www.b1gmail.org/';
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
// plugin info
|
||||
$this->type = BMPLUGIN_WIDGET;
|
||||
$this->name = 'News widget';
|
||||
$this->author = 'b1gMail Project';
|
||||
$this->mail = 'info@b1gmail.org';
|
||||
$this->version = '1.7';
|
||||
$this->widgetTemplate = 'widget.news.tpl';
|
||||
$this->widgetTitle = 'News';
|
||||
$this->update_url = 'https://service.b1gmail.org/plugin_updates/';
|
||||
$this->website = 'https://www.b1gmail.org/';
|
||||
}
|
||||
|
||||
function isWidgetSuitable($for)
|
||||
{
|
||||
return($for == BMWIDGET_START
|
||||
|| $for == BMWIDGET_ORGANIZER);
|
||||
}
|
||||
public function isWidgetSuitable($for)
|
||||
{
|
||||
return $for == BMWIDGET_START
|
||||
|| $for == BMWIDGET_ORGANIZER;
|
||||
}
|
||||
|
||||
function renderWidget()
|
||||
{
|
||||
global $groupRow, $tpl;
|
||||
$tpl->assign('bmwidget_news_news', NewsPlugin::_getNews(true, $groupRow['id']));
|
||||
return(true);
|
||||
}
|
||||
public function renderWidget()
|
||||
{
|
||||
global $groupRow, $tpl;
|
||||
$tpl->assign('bmwidget_news_news', (new NewsPlugin())->_getNews(true, $groupRow['id']));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* register plugin + widget
|
||||
*/
|
||||
$plugins->registerPlugin('NewsPlugin');
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
*
|
||||
*/
|
||||
class modopenfire extends BMPlugin
|
||||
{
|
||||
/*
|
||||
* Eigenschaften des Plugins
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->name = 'Jabber Openfire-Integration';
|
||||
{
|
||||
/*
|
||||
* Eigenschaften des Plugins
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->name = 'Jabber Openfire-Integration';
|
||||
$this->version = '1.1.1';
|
||||
$this->type = BMPLUGIN_DEFAULT;
|
||||
|
||||
|
@ -36,203 +36,213 @@ class modopenfire extends BMPlugin
|
|||
$this->admin_pages = true;
|
||||
$this->admin_page_title = 'Openfire-Integration';
|
||||
$this->admin_page_icon = "openfire_icon.png";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* installation routine
|
||||
*/
|
||||
function Install()
|
||||
{
|
||||
global $db;
|
||||
/*
|
||||
* installation routine
|
||||
*/
|
||||
public function Install()
|
||||
{
|
||||
global $db;
|
||||
|
||||
// create mod_openfire table utf8
|
||||
$db->Query("CREATE TABLE `{pre}mod_openfire` (
|
||||
// create mod_openfire table utf8
|
||||
$db->Query('CREATE TABLE `{pre}mod_openfire` (
|
||||
`enableAuth` tinyint(1) NOT NULL,
|
||||
`secretkey` varchar(255) NOT NULL,
|
||||
`domain` varchar(255) NOT NULL,
|
||||
`port` int(10) NOT NULL,
|
||||
`https` tinyint(1) NOT NULL
|
||||
) ENGINE=MyISAM;");
|
||||
) ENGINE=MyISAM;');
|
||||
|
||||
$db->Query("REPLACE INTO {pre}mod_openfire (enableAuth, secretkey, domain, port, https) VALUES (?,?,?,?,?);",
|
||||
(int) 0,
|
||||
'YourSecretKey',
|
||||
'localhost',
|
||||
(int) 9091,
|
||||
(int) 1);
|
||||
$db->Query('REPLACE INTO {pre}mod_openfire (enableAuth, secretkey, domain, port, https) VALUES (?,?,?,?,?);',
|
||||
(int) 0,
|
||||
'YourSecretKey',
|
||||
'localhost',
|
||||
(int) 9091,
|
||||
(int) 1);
|
||||
|
||||
PutLog('Plugin "'. $this->name .' - '. $this->version .'" wurde erfolgreich installiert.', PRIO_PLUGIN, __FILE__, __LINE__);
|
||||
return(true);
|
||||
}
|
||||
PutLog('Plugin "'.$this->name.' - '.$this->version.'" wurde erfolgreich installiert.', PRIO_PLUGIN, __FILE__, __LINE__);
|
||||
|
||||
/*
|
||||
* uninstallation routine
|
||||
*/
|
||||
function Uninstall()
|
||||
{
|
||||
global $db;
|
||||
return true;
|
||||
}
|
||||
|
||||
// drop von mod_openfire
|
||||
$db->Query("DROP TABLE {pre}mod_openfire;");
|
||||
/*
|
||||
* uninstallation routine
|
||||
*/
|
||||
public function Uninstall()
|
||||
{
|
||||
global $db;
|
||||
|
||||
PutLog('Plugin "'. $this->name .' - '. $this->version .'" wurde erfolgreich deinstalliert.', PRIO_PLUGIN, __FILE__, __LINE__);
|
||||
return(true);
|
||||
}
|
||||
// drop von mod_openfire
|
||||
$db->Query('DROP TABLE {pre}mod_openfire;');
|
||||
|
||||
/*
|
||||
* Link und Tabs im Adminbereich
|
||||
*/
|
||||
function AdminHandler()
|
||||
{
|
||||
global $db, $tpl, $lang_admin;
|
||||
PutLog('Plugin "'.$this->name.' - '.$this->version.'" wurde erfolgreich deinstalliert.', PRIO_PLUGIN, __FILE__, __LINE__);
|
||||
|
||||
$tabs = array(
|
||||
0 => array(
|
||||
'title' => $lang_admin['prefs'],
|
||||
'link' => $this->_adminLink() . '&',
|
||||
'active' => $_REQUEST['plugin'] == 'modopenfire',
|
||||
'icon' => '../plugins/templates/images/openfire_logo.png'
|
||||
)
|
||||
);
|
||||
$tpl->assign('tabs', $tabs);
|
||||
return true;
|
||||
}
|
||||
|
||||
if(isset($_POST['save']))
|
||||
{
|
||||
$db->Query("UPDATE {pre}mod_openfire SET domain=?,secretkey=?,enableAuth=?,port=?,https=?",
|
||||
$_POST['openfire_domain'],
|
||||
$_POST['openfire_userservice_secretkey'],
|
||||
(int) isset($_POST['openfire_enableAuth']) ? 1 : 0,
|
||||
(int) $_POST['openfire_port'],
|
||||
(int) isset($_POST['openfire_https']) ? 1 : 0);
|
||||
/*
|
||||
* Link und Tabs im Adminbereich
|
||||
*/
|
||||
public function AdminHandler()
|
||||
{
|
||||
global $db, $tpl, $lang_admin;
|
||||
|
||||
$tpl->assign('erfolg', "<b>Die Daten wurden erfolgreich aktualisiert!</b><br />");
|
||||
}
|
||||
$tabs = [
|
||||
0 => [
|
||||
'title' => $lang_admin['prefs'],
|
||||
'link' => $this->_adminLink().'&',
|
||||
'active' => $_REQUEST['plugin'] == 'modopenfire',
|
||||
'icon' => '../plugins/templates/images/openfire_logo.png',
|
||||
],
|
||||
];
|
||||
$tpl->assign('tabs', $tabs);
|
||||
|
||||
$res = $db->Query("SELECT enableAuth, secretkey, domain, port, https FROM {pre}mod_openfire");
|
||||
$openfire_prefs = $res->FetchArray();
|
||||
$res->Free();
|
||||
if (isset($_POST['save'])) {
|
||||
$db->Query('UPDATE {pre}mod_openfire SET domain=?,secretkey=?,enableAuth=?,port=?,https=?',
|
||||
$_POST['openfire_domain'],
|
||||
$_POST['openfire_userservice_secretkey'],
|
||||
(int) isset($_POST['openfire_enableAuth']) ? 1 : 0,
|
||||
(int) $_POST['openfire_port'],
|
||||
(int) isset($_POST['openfire_https']) ? 1 : 0);
|
||||
|
||||
$tpl->assign('openfire_prefs', $openfire_prefs);
|
||||
$tpl->assign('pageURL', $this->_adminLink());
|
||||
$tpl->assign('page', $this->_templatePath('openfire.plugin.prefs.tpl'));
|
||||
}
|
||||
$tpl->assign('erfolg', '<b>'.$lang_admin['openfire_updated_data'].'</b><br />');
|
||||
}
|
||||
|
||||
/*
|
||||
* Sprach variablen
|
||||
*/
|
||||
function OnReadLang(&$lang_user, &$lang_client, &$lang_custom, &$lang_admin, $lang)
|
||||
{
|
||||
$lang_admin['openfire_domain'] = 'Openfire-Domain';
|
||||
$lang_admin['openfire_port'] = 'Openfire Adminport';
|
||||
$lang_admin['openfire_https'] = 'HTTPS für Adminbereich nutzen';
|
||||
$lang_admin['openfire_secretkey'] = 'Secret Key vom User Service Plugin';
|
||||
}
|
||||
$res = $db->Query('SELECT enableAuth, secretkey, domain, port, https FROM {pre}mod_openfire');
|
||||
$openfire_prefs = $res->FetchArray();
|
||||
$res->Free();
|
||||
|
||||
/*
|
||||
* OnSignup
|
||||
*/
|
||||
function OnSignup($userid, $usermail)
|
||||
{
|
||||
global $suEMailLocal, $suPass1, $suEMail, $suFirstname, $suSurname;
|
||||
$tpl->assign('openfire_prefs', $openfire_prefs);
|
||||
$tpl->assign('pageURL', $this->_adminLink());
|
||||
$tpl->assign('page', $this->_templatePath('openfire.plugin.prefs.tpl'));
|
||||
}
|
||||
|
||||
if($this->_enableAuth())
|
||||
{
|
||||
$benutzername = trim($suEMailLocal);
|
||||
$jabber_kennwort = trim($suPass1);
|
||||
$voller_name = trim($suFirstname)." ".trim($suSurname);
|
||||
/*
|
||||
* Sprach variablen
|
||||
*/
|
||||
public function OnReadLang(&$lang_user, &$lang_client, &$lang_custom, &$lang_admin, $lang)
|
||||
{
|
||||
if ($lang == 'deutsch') {
|
||||
$lang_admin['openfire_domain'] = 'Openfire-Domain';
|
||||
$lang_admin['openfire_port'] = 'Openfire Adminport';
|
||||
$lang_admin['openfire_https'] = 'HTTPS für Adminbereich nutzen';
|
||||
$lang_admin['openfire_secretkey'] = 'Secret Key vom User Service Plugin';
|
||||
$lang_admin['openfire_updated_data'] = 'Die Daten wurden erfolgreich aktualisiert!';
|
||||
}
|
||||
else {
|
||||
$lang_admin['openfire_domain'] = 'Openfire Domain';
|
||||
$lang_admin['openfire_port'] = 'Openfire Adminport';
|
||||
$lang_admin['openfire_https'] = 'Use HTTPS for Admin?';
|
||||
$lang_admin['openfire_secretkey'] = 'Secret Key of User Service Plugin';
|
||||
$lang_admin['openfire_updated_data'] = 'Data successfully updated!';
|
||||
}
|
||||
}
|
||||
|
||||
$url = $this->_getUrl()."&type=add&username=".$this->_toRawUrl($benutzername)."&password=".$this->_toRawUrl($jabber_kennwort)."&name=".$this->_toRawUrl($voller_name)."&email=".$this->_toRawUrl($suEMail);
|
||||
$this->_sendhttp($url);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* OnSignup
|
||||
*/
|
||||
public function OnSignup($userid, $usermail)
|
||||
{
|
||||
global $suEMailLocal, $suPass1, $suEMail, $suFirstname, $suSurname;
|
||||
|
||||
/*
|
||||
* OnDeleteUser
|
||||
*/
|
||||
function OnDeleteUser($id)
|
||||
{
|
||||
global $db;
|
||||
if ($this->_enableAuth()) {
|
||||
$benutzername = trim($suEMailLocal);
|
||||
$jabber_kennwort = trim($suPass1);
|
||||
$voller_name = trim($suFirstname).' '.trim($suSurname);
|
||||
|
||||
if($this->_enableAuth())
|
||||
{
|
||||
$res = $db->Query("SELECT email FROM {pre}users WHERE id=?",
|
||||
$id);
|
||||
$jabber = $res->FetchArray();
|
||||
$res->Free();
|
||||
|
||||
$benutzername = explode("@", $jabber['email']);
|
||||
$url = $this->_getUrl().'&type=add&username='.$this->_toRawUrl($benutzername).'&password='.$this->_toRawUrl($jabber_kennwort).'&name='.$this->_toRawUrl($voller_name).'&email='.$this->_toRawUrl($suEMail);
|
||||
$this->_sendhttp($url);
|
||||
}
|
||||
}
|
||||
|
||||
$url = $this->_getUrl()."&type=delete&username=".$this->_toRawUrl($benutzername[0]);
|
||||
$this->_sendhttp($url);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* OnDeleteUser
|
||||
*/
|
||||
public function OnDeleteUser($id)
|
||||
{
|
||||
global $db;
|
||||
|
||||
function OnUserPasswordChange($userID, $oldPasswordMD5, $newPasswordMD5, $newPasswordPlain)
|
||||
{
|
||||
global $userRow;
|
||||
if ($this->_enableAuth()) {
|
||||
$res = $db->Query('SELECT email FROM {pre}users WHERE id=?',
|
||||
$id);
|
||||
$jabber = $res->FetchArray();
|
||||
$res->Free();
|
||||
|
||||
if($this->_enableAuth())
|
||||
{
|
||||
$voller_name = trim($userRow['vorname'])." ".trim($userRow['nachname']);
|
||||
$benutzername = explode("@", $userRow['email']);
|
||||
$benutzername = explode('@', $jabber['email']);
|
||||
|
||||
$url = $this->_getUrl()."&type=update&username=".$this->_toRawUrl($benutzername[0])."&password=".$this->_toRawUrl($newPasswordPlain)."&name=".$this->_toRawUrl($voller_name)."&email=".$this->_toRawUrl($userRow['email']);
|
||||
$this->_sendhttp($url);
|
||||
}
|
||||
}
|
||||
$url = $this->_getUrl().'&type=delete&username='.$this->_toRawUrl($benutzername[0]);
|
||||
$this->_sendhttp($url);
|
||||
}
|
||||
}
|
||||
|
||||
function _getUrl()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$res = $db->Query("SELECT https, domain, port, secretkey FROM {pre}mod_openfire");
|
||||
$jabber_row = $res->FetchArray();
|
||||
$res->Free();
|
||||
public function OnUserPasswordChange($userID, $oldPasswordMD5, $newPasswordMD5, $newPasswordPlain)
|
||||
{
|
||||
global $userRow;
|
||||
|
||||
if($jabber_row['https'] == 1)
|
||||
{
|
||||
$http_modus = "https";
|
||||
} else {
|
||||
$http_modus = "http";
|
||||
}
|
||||
return $http_modus."://".$jabber_row['domain'].":".$jabber_row['port']."/plugins/userService/userservice?secret=".$jabber_row['secretkey'];
|
||||
}
|
||||
if ($this->_enableAuth()) {
|
||||
$voller_name = trim($userRow['vorname']).' '.trim($userRow['nachname']);
|
||||
$benutzername = explode('@', $userRow['email']);
|
||||
|
||||
function _enableAuth()
|
||||
{
|
||||
global $db;
|
||||
|
||||
$res = $db->Query("SELECT enableAuth FROM {pre}mod_openfire");
|
||||
$jabber_row = $res->FetchArray();
|
||||
$res->Free();
|
||||
$url = $this->_getUrl().'&type=update&username='.$this->_toRawUrl($benutzername[0]).'&password='.$this->_toRawUrl($newPasswordPlain).'&name='.$this->_toRawUrl($voller_name).'&email='.$this->_toRawUrl($userRow['email']);
|
||||
$this->_sendhttp($url);
|
||||
}
|
||||
}
|
||||
|
||||
if($jabber_row['enableAuth'] == 1)
|
||||
return true;
|
||||
public function _getUrl()
|
||||
{
|
||||
global $db;
|
||||
|
||||
return false;
|
||||
}
|
||||
$res = $db->Query('SELECT https, domain, port, secretkey FROM {pre}mod_openfire');
|
||||
$jabber_row = $res->FetchArray();
|
||||
$res->Free();
|
||||
|
||||
function _sendhttp($url)
|
||||
{
|
||||
if(!class_exists('BMHTTP'))
|
||||
include(B1GMAIL_DIR . 'serverlib/http.class.php');
|
||||
if ($jabber_row['https'] == 1) {
|
||||
$http_modus = 'https';
|
||||
} else {
|
||||
$http_modus = 'http';
|
||||
}
|
||||
|
||||
$http = _new('BMHTTP', array($url));
|
||||
$result = $http->DownloadToString();
|
||||
}
|
||||
return $http_modus.'://'.$jabber_row['domain'].':'.$jabber_row['port'].'/plugins/userService/userservice?secret='.$jabber_row['secretkey'];
|
||||
}
|
||||
|
||||
function _toRawUrl($text)
|
||||
{
|
||||
global $bm_prefs;
|
||||
public function _enableAuth()
|
||||
{
|
||||
global $db;
|
||||
|
||||
if(!$bm_prefs['db_is_utf8'])
|
||||
$text = utf8_encode($text);
|
||||
$res = $db->Query('SELECT enableAuth FROM {pre}mod_openfire');
|
||||
$jabber_row = $res->FetchArray();
|
||||
$res->Free();
|
||||
|
||||
return rawurlencode($text);
|
||||
}
|
||||
if ($jabber_row['enableAuth'] == 1) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function _sendhttp($url)
|
||||
{
|
||||
if (!class_exists('BMHTTP')) {
|
||||
include B1GMAIL_DIR.'serverlib/http.class.php';
|
||||
}
|
||||
|
||||
$http = _new('BMHTTP', [$url]);
|
||||
$result = $http->DownloadToString();
|
||||
}
|
||||
|
||||
public function _toRawUrl($text)
|
||||
{
|
||||
global $bm_prefs;
|
||||
|
||||
if (!$bm_prefs['db_is_utf8']) {
|
||||
$text = utf8_encode($text);
|
||||
}
|
||||
|
||||
return rawurlencode($text);
|
||||
}
|
||||
}
|
||||
/**
|
||||
/*
|
||||
* register plugin
|
||||
*/
|
||||
$plugins->registerPlugin('modopenfire');
|
||||
?>
|
|
@ -20,151 +20,141 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* Plugin update notifier plugin
|
||||
*
|
||||
* Plugin update notifier plugin.
|
||||
*/
|
||||
class PluginUpdatesPlugin extends BMPlugin
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
// plugin info
|
||||
$this->type = BMPLUGIN_DEFAULT;
|
||||
$this->name = 'Plugin Updates';
|
||||
$this->author = 'b1gMail Project';
|
||||
$this->mail = 'info@b1gmail.org';
|
||||
$this->version = '1.2';
|
||||
$this->update_url = 'https://service.b1gmail.org/plugin_updates/';
|
||||
$this->website = 'https://www.b1gmail.org/';
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
// plugin info
|
||||
$this->type = BMPLUGIN_DEFAULT;
|
||||
$this->name = 'Plugin Updates';
|
||||
$this->author = 'b1gMail Project';
|
||||
$this->mail = 'info@b1gmail.org';
|
||||
$this->version = '1.2';
|
||||
$this->update_url = 'https://service.b1gmail.org/plugin_updates/';
|
||||
$this->website = 'https://www.b1gmail.org/';
|
||||
}
|
||||
|
||||
function Install()
|
||||
{
|
||||
global $db;
|
||||
public function Install()
|
||||
{
|
||||
global $db;
|
||||
|
||||
// db struct
|
||||
$databaseStructure = // checksum: 3fcac3f06a07e9ebdda20613c81ebec2
|
||||
'YToxOntzOjIyOiJibTYwX21vZF9wbHVnaW51cGRhdGVzIjthOjI6e3M6NjoiZmllbGRzIjthOjM'
|
||||
. '6e2k6MDthOjY6e2k6MDtzOjc6Im1vZE5hbWUiO2k6MTtzOjExOiJ2YXJjaGFyKDMyKSI7aToyO3'
|
||||
. 'M6MjoiTk8iO2k6MztzOjM6IlBSSSI7aTo0O3M6MDoiIjtpOjU7czowOiIiO31pOjE7YTo2OntpO'
|
||||
. 'jA7czoxMzoibGF0ZXN0VmVyc2lvbiI7aToxO3M6MTA6InZhcmNoYXIoOCkiO2k6MjtzOjI6Ik5P'
|
||||
. 'IjtpOjM7czowOiIiO2k6NDtOO2k6NTtzOjA6IiI7fWk6MjthOjY6e2k6MDtzOjk6Imxhc3RDaGV'
|
||||
. 'jayI7aToxO3M6NzoiaW50KDExKSI7aToyO3M6MjoiTk8iO2k6MztzOjM6Ik1VTCI7aTo0O3M6MT'
|
||||
. 'oiMCI7aTo1O3M6MDoiIjt9fXM6NzoiaW5kZXhlcyI7YToyOntzOjc6IlBSSU1BUlkiO2E6MTp7a'
|
||||
. 'TowO3M6NzoibW9kTmFtZSI7fXM6OToibGFzdENoZWNrIjthOjE6e2k6MDtzOjk6Imxhc3RDaGVj'
|
||||
. 'ayI7fX19fQ==';
|
||||
$databaseStructure = unserialize(base64_decode($databaseStructure));
|
||||
// db struct
|
||||
$databaseStructure = // checksum: 3fcac3f06a07e9ebdda20613c81ebec2
|
||||
'YToxOntzOjIyOiJibTYwX21vZF9wbHVnaW51cGRhdGVzIjthOjI6e3M6NjoiZmllbGRzIjthOjM'
|
||||
.'6e2k6MDthOjY6e2k6MDtzOjc6Im1vZE5hbWUiO2k6MTtzOjExOiJ2YXJjaGFyKDMyKSI7aToyO3'
|
||||
.'M6MjoiTk8iO2k6MztzOjM6IlBSSSI7aTo0O3M6MDoiIjtpOjU7czowOiIiO31pOjE7YTo2OntpO'
|
||||
.'jA7czoxMzoibGF0ZXN0VmVyc2lvbiI7aToxO3M6MTA6InZhcmNoYXIoOCkiO2k6MjtzOjI6Ik5P'
|
||||
.'IjtpOjM7czowOiIiO2k6NDtOO2k6NTtzOjA6IiI7fWk6MjthOjY6e2k6MDtzOjk6Imxhc3RDaGV'
|
||||
.'jayI7aToxO3M6NzoiaW50KDExKSI7aToyO3M6MjoiTk8iO2k6MztzOjM6Ik1VTCI7aTo0O3M6MT'
|
||||
.'oiMCI7aTo1O3M6MDoiIjt9fXM6NzoiaW5kZXhlcyI7YToyOntzOjc6IlBSSU1BUlkiO2E6MTp7a'
|
||||
.'TowO3M6NzoibW9kTmFtZSI7fXM6OToibGFzdENoZWNrIjthOjE6e2k6MDtzOjk6Imxhc3RDaGVj'
|
||||
.'ayI7fX19fQ==';
|
||||
$databaseStructure = unserialize(base64_decode($databaseStructure));
|
||||
|
||||
// sync struct
|
||||
SyncDBStruct($databaseStructure);
|
||||
// sync struct
|
||||
SyncDBStruct($databaseStructure);
|
||||
|
||||
// log
|
||||
PutLog(sprintf('%s v%s installed',
|
||||
$this->name,
|
||||
$this->version),
|
||||
PRIO_PLUGIN,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
// log
|
||||
PutLog(sprintf('%s v%s installed',
|
||||
$this->name,
|
||||
$this->version),
|
||||
PRIO_PLUGIN,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
|
||||
return(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function OnReadLang(&$lang_user, &$lang_client, &$lang_custom, &$lang_admin, $lang)
|
||||
{
|
||||
if($lang == 'deutsch')
|
||||
{
|
||||
$lang_admin['pluginupd_notification'] = 'Für die folgenden Plugins stehen Updates zur Verfügung:';
|
||||
}
|
||||
else
|
||||
{
|
||||
$lang_admin['pluginupd_notification'] = 'Updates for the following plugins are available:';
|
||||
}
|
||||
}
|
||||
public function OnReadLang(&$lang_user, &$lang_client, &$lang_custom, &$lang_admin, $lang)
|
||||
{
|
||||
if ($lang == 'deutsch') {
|
||||
$lang_admin['pluginupd_notification'] = 'Für die folgenden Plugins stehen Updates zur Verfügung:';
|
||||
} else {
|
||||
$lang_admin['pluginupd_notification'] = 'Updates for the following plugins are available:';
|
||||
}
|
||||
}
|
||||
|
||||
function OnCron()
|
||||
{
|
||||
global $plugins, $db;
|
||||
public function OnCron()
|
||||
{
|
||||
global $plugins, $db;
|
||||
|
||||
$table = array();
|
||||
$res = $db->Query('SELECT `modName`,`lastCheck`,`latestVersion` FROM {pre}mod_pluginupdates');
|
||||
while($row = $res->FetchArray())
|
||||
{
|
||||
$table[$row['modName']] = $row;
|
||||
}
|
||||
$res->Free();
|
||||
$table = [];
|
||||
$res = $db->Query('SELECT `modName`,`lastCheck`,`latestVersion` FROM {pre}mod_pluginupdates');
|
||||
while ($row = $res->FetchArray()) {
|
||||
$table[$row['modName']] = $row;
|
||||
}
|
||||
$res->Free();
|
||||
|
||||
$startTime = time();
|
||||
$startTime = time();
|
||||
|
||||
foreach($plugins->_plugins as $className=>$pluginInfo)
|
||||
{
|
||||
if(!isset($table[$className])
|
||||
|| $table[$className]['lastCheck']+3*TIME_ONE_HOUR <= time())
|
||||
{
|
||||
$latestVersion = '';
|
||||
$resultCode = $plugins->callFunction('CheckForUpdates', $className, false, array(&$latestVersion));
|
||||
foreach ($plugins->_plugins as $className => $pluginInfo) {
|
||||
if (!isset($table[$className])
|
||||
|| $table[$className]['lastCheck'] + 3 * TIME_ONE_HOUR <= time()) {
|
||||
$latestVersion = '';
|
||||
$resultCode = $plugins->callFunction('CheckForUpdates', $className, false, [&$latestVersion]);
|
||||
|
||||
$db->Query('REPLACE INTO {pre}mod_pluginupdates(`modName`,`lastCheck`,`latestVersion`) VALUES(?,?,?)',
|
||||
$className,
|
||||
time(),
|
||||
$latestVersion);
|
||||
}
|
||||
$db->Query('REPLACE INTO {pre}mod_pluginupdates(`modName`,`lastCheck`,`latestVersion`) VALUES(?,?,?)',
|
||||
$className,
|
||||
time(),
|
||||
$latestVersion);
|
||||
}
|
||||
|
||||
// allow max. 2 seconds for update checking
|
||||
if(time() > $startTime + 2)
|
||||
break;
|
||||
}
|
||||
}
|
||||
// allow max. 2 seconds for update checking
|
||||
if (time() > $startTime + 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getNotices()
|
||||
{
|
||||
global $db, $plugins, $lang_admin;
|
||||
public function getNotices()
|
||||
{
|
||||
global $db, $plugins, $lang_admin;
|
||||
|
||||
$result = array();
|
||||
$result = [];
|
||||
|
||||
$outdatedPlugins = array();
|
||||
$res = $db->Query('SELECT `modName`,`latestVersion` FROM {pre}mod_pluginupdates WHERE `latestVersion`!=? ORDER BY `modName` ASC',
|
||||
'');
|
||||
while($row = $res->FetchArray(MYSQLI_ASSOC))
|
||||
{
|
||||
if(isset($plugins->_plugins[$row['modName']]))
|
||||
{
|
||||
$pluginVersion = $plugins->getParam('version', $row['modName']);
|
||||
$outdatedPlugins = [];
|
||||
$res = $db->Query('SELECT `modName`,`latestVersion` FROM {pre}mod_pluginupdates WHERE `latestVersion`!=? ORDER BY `modName` ASC',
|
||||
'');
|
||||
while ($row = $res->FetchArray(MYSQLI_ASSOC)) {
|
||||
if (isset($plugins->_plugins[$row['modName']])) {
|
||||
$pluginVersion = $plugins->getParam('version', $row['modName']);
|
||||
|
||||
if($plugins->callFunction('IsVersionNewer', $row['modName'], false, array($row['latestVersion'], $pluginVersion)))
|
||||
$outdatedPlugins[] = array(
|
||||
'name' => $plugins->getParam('name', $row['modName']),
|
||||
'website' => $plugins->getParam('website', $row['modName']),
|
||||
'installed' => $plugins->getParam('version', $row['modName']),
|
||||
'available' => $row['latestVersion']
|
||||
);
|
||||
}
|
||||
}
|
||||
$res->Free();
|
||||
if ($plugins->callFunction('IsVersionNewer', $row['modName'], false, [$row['latestVersion'], $pluginVersion])) {
|
||||
$outdatedPlugins[] = [
|
||||
'name' => $plugins->getParam('name', $row['modName']),
|
||||
'website' => $plugins->getParam('website', $row['modName']),
|
||||
'installed' => $plugins->getParam('version', $row['modName']),
|
||||
'available' => $row['latestVersion'],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
$res->Free();
|
||||
|
||||
if(count($outdatedPlugins) > 0)
|
||||
{
|
||||
$text = $lang_admin['pluginupd_notification'] . ' ';
|
||||
foreach($outdatedPlugins as $plugin)
|
||||
{
|
||||
$text .= sprintf('<b><a href="%s" target="_blank">%s</a></b> (%s), ',
|
||||
$plugin['website'],
|
||||
HTMLFormat($plugin['name']),
|
||||
HTMLFormat($plugin['available']));
|
||||
}
|
||||
$text = substr($text, 0, -2);
|
||||
if (count($outdatedPlugins) > 0) {
|
||||
$text = $lang_admin['pluginupd_notification'].' ';
|
||||
foreach ($outdatedPlugins as $plugin) {
|
||||
$text .= sprintf('<b><a href="%s" target="_blank">%s</a></b> (%s), ',
|
||||
$plugin['website'],
|
||||
HTMLFormat($plugin['name']),
|
||||
HTMLFormat($plugin['available']));
|
||||
}
|
||||
$text = substr($text, 0, -2);
|
||||
|
||||
$result[] = array(
|
||||
'type' => 'info',
|
||||
'text' => $text,
|
||||
'link' => 'plugins.php?action=updates&'
|
||||
);
|
||||
}
|
||||
$result[] = [
|
||||
'type' => 'info',
|
||||
'text' => $text,
|
||||
'link' => 'plugins.php?action=updates&',
|
||||
];
|
||||
}
|
||||
|
||||
return($result);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* register plugin
|
||||
*/
|
||||
$plugins->registerPlugin('PluginUpdatesPlugin');
|
||||
?>
|
|
@ -20,176 +20,164 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* PLZ editor plugin
|
||||
*
|
||||
* PLZ editor plugin.
|
||||
*/
|
||||
class PLZEditorPlugin extends BMPlugin
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
// plugin info
|
||||
$this->type = BMPLUGIN_DEFAULT;
|
||||
$this->name = 'PLZ-Editor';
|
||||
$this->author = 'b1gMail Project';
|
||||
$this->mail = 'info@b1gmail.org';
|
||||
$this->version = '1.5';
|
||||
$this->update_url = 'https://service.b1gmail.org/plugin_updates/';
|
||||
$this->website = 'https://www.b1gmail.org/';
|
||||
public function __construct()
|
||||
{
|
||||
// plugin info
|
||||
$this->type = BMPLUGIN_DEFAULT;
|
||||
$this->name = 'PLZ-Editor';
|
||||
$this->author = 'b1gMail Project';
|
||||
$this->mail = 'info@b1gmail.org';
|
||||
$this->version = '1.5';
|
||||
$this->update_url = 'https://service.b1gmail.org/plugin_updates/';
|
||||
$this->website = 'https://www.b1gmail.org/';
|
||||
|
||||
$this->admin_pages = true;
|
||||
$this->admin_page_title = 'PLZ-Editor';
|
||||
}
|
||||
$this->admin_pages = true;
|
||||
$this->admin_page_title = 'PLZ-Editor';
|
||||
}
|
||||
|
||||
function OnReadLang(&$lang_user, &$lang_client, &$lang_custom, &$lang_admin, $lang)
|
||||
{
|
||||
if($lang == 'deutsch')
|
||||
{
|
||||
$lang_admin['plzeditor_title'] = 'PLZ-Editor';
|
||||
$lang_admin['plzeditor_test'] = 'PLZ testen';
|
||||
$lang_admin['plzeditor_add'] = 'PLZ hinzufügen';
|
||||
$lang_admin['plzeditor_zip'] = 'PLZ';
|
||||
$lang_admin['plzeditor_city'] = 'Ort';
|
||||
$lang_admin['plzeditor_test_success'] = 'Das PLZ/Ort-Paar "%s %s" wurde in der PLZ-Datenbank von %s gefunden.';
|
||||
$lang_admin['plzeditor_test_error'] = 'Das PLZ/Ort-Paar "%s %s" wurde <b>nicht</b> in der PLZ-Datenbank von %s gefunden.';
|
||||
$lang_admin['plzeditor_add_success'] = 'Das PLZ/Ort-Paar "%s %s" wurde in die PLZ-Datenbank von %s eingefügt.';
|
||||
$lang_admin['plzeditor_add_error'] = 'Das PLZ/Ort-Paar konnte nicht hinzugefügt werden. Bitte stellen Sie sicher, dass die Datei <code>%s</code> Schreibrechte hat (CHMOD 777).';
|
||||
}
|
||||
else
|
||||
{
|
||||
$lang_admin['plzeditor_title'] = 'ZIP editor';
|
||||
$lang_admin['plzeditor_test'] = 'Test ZIP code';
|
||||
$lang_admin['plzeditor_add'] = 'Add ZIP code';
|
||||
$lang_admin['plzeditor_zip'] = 'ZIP';
|
||||
$lang_admin['plzeditor_city'] = 'City';
|
||||
$lang_admin['plzeditor_test_success'] = 'The ZIP/city pair "%s %s" exists in the ZIP database of %s.';
|
||||
$lang_admin['plzeditor_test_error'] = 'The ZIP/city pair "%s %s" <b>does not</b> exist in the ZIP database of %s.';
|
||||
$lang_admin['plzeditor_add_success'] = 'The ZIP/city pair "%s %s" has been added to the ZIP database of %s.';
|
||||
$lang_admin['plzeditor_add_error'] = 'The ZIP/city pair could not be added. Please ensure that the file <code>%s</code> has write permissions (CHMOD 777).';
|
||||
}
|
||||
}
|
||||
public function OnReadLang(&$lang_user, &$lang_client, &$lang_custom, &$lang_admin, $lang)
|
||||
{
|
||||
if ($lang == 'deutsch') {
|
||||
$lang_admin['plzeditor_title'] = 'PLZ-Editor';
|
||||
$lang_admin['plzeditor_test'] = 'PLZ testen';
|
||||
$lang_admin['plzeditor_add'] = 'PLZ hinzufügen';
|
||||
$lang_admin['plzeditor_zip'] = 'PLZ';
|
||||
$lang_admin['plzeditor_city'] = 'Ort';
|
||||
$lang_admin['plzeditor_test_success'] = 'Das PLZ/Ort-Paar "%s %s" wurde in der PLZ-Datenbank von %s gefunden.';
|
||||
$lang_admin['plzeditor_test_error'] = 'Das PLZ/Ort-Paar "%s %s" wurde <b>nicht</b> in der PLZ-Datenbank von %s gefunden.';
|
||||
$lang_admin['plzeditor_add_success'] = 'Das PLZ/Ort-Paar "%s %s" wurde in die PLZ-Datenbank von %s eingefügt.';
|
||||
$lang_admin['plzeditor_add_error'] = 'Das PLZ/Ort-Paar konnte nicht hinzugefügt werden. Bitte stellen Sie sicher, dass die Datei <code>%s</code> Schreibrechte hat (CHMOD 777).';
|
||||
} else {
|
||||
$lang_admin['plzeditor_title'] = 'ZIP editor';
|
||||
$lang_admin['plzeditor_test'] = 'Test ZIP code';
|
||||
$lang_admin['plzeditor_add'] = 'Add ZIP code';
|
||||
$lang_admin['plzeditor_zip'] = 'ZIP';
|
||||
$lang_admin['plzeditor_city'] = 'City';
|
||||
$lang_admin['plzeditor_test_success'] = 'The ZIP/city pair "%s %s" exists in the ZIP database of %s.';
|
||||
$lang_admin['plzeditor_test_error'] = 'The ZIP/city pair "%s %s" <b>does not</b> exist in the ZIP database of %s.';
|
||||
$lang_admin['plzeditor_add_success'] = 'The ZIP/city pair "%s %s" has been added to the ZIP database of %s.';
|
||||
$lang_admin['plzeditor_add_error'] = 'The ZIP/city pair could not be added. Please ensure that the file <code>%s</code> has write permissions (CHMOD 777).';
|
||||
}
|
||||
}
|
||||
|
||||
function AdminHandler()
|
||||
{
|
||||
global $tpl, $bm_prefs, $lang_admin;
|
||||
public function AdminHandler()
|
||||
{
|
||||
global $tpl, $bm_prefs, $lang_admin;
|
||||
|
||||
if(!isset($_REQUEST['action']))
|
||||
$_REQUEST['action'] = 'editor';
|
||||
if (!isset($_REQUEST['action'])) {
|
||||
$_REQUEST['action'] = 'editor';
|
||||
}
|
||||
|
||||
$tabs = array(
|
||||
0 => array(
|
||||
'title' => $lang_admin['plzeditor_title'],
|
||||
'link' => $this->_adminLink() . '&',
|
||||
'active' => $_REQUEST['action'] == 'editor'
|
||||
)
|
||||
);
|
||||
$tabs = [
|
||||
0 => [
|
||||
'title' => $lang_admin['plzeditor_title'],
|
||||
'link' => $this->_adminLink().'&',
|
||||
'active' => $_REQUEST['action'] == 'editor',
|
||||
],
|
||||
];
|
||||
|
||||
$countryList = CountryList();
|
||||
$countryList = CountryList();
|
||||
|
||||
$tpl->assign('tabs', $tabs);
|
||||
$tpl->assign('tabs', $tabs);
|
||||
|
||||
if($_REQUEST['action'] == 'editor')
|
||||
{
|
||||
if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'test')
|
||||
{
|
||||
$result = ZIPCheck(trim($_REQUEST['zip']),
|
||||
trim($_REQUEST['city']),
|
||||
(int)$_REQUEST['country']);
|
||||
if ($_REQUEST['action'] == 'editor') {
|
||||
if (isset($_REQUEST['do']) && $_REQUEST['do'] == 'test') {
|
||||
$result = ZIPCheck(trim($_REQUEST['zip']),
|
||||
trim($_REQUEST['city']),
|
||||
(int) $_REQUEST['country']);
|
||||
|
||||
if($result)
|
||||
{
|
||||
$tpl->assign('success', sprintf($lang_admin['plzeditor_test_success'],
|
||||
htmlentities(trim($_REQUEST['zip'])),
|
||||
htmlentities(trim($_REQUEST['city'])),
|
||||
$countryList[$_REQUEST['country']]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$tpl->assign('error', sprintf($lang_admin['plzeditor_test_error'],
|
||||
htmlentities(trim($_REQUEST['zip'])),
|
||||
htmlentities(trim($_REQUEST['city'])),
|
||||
$countryList[$_REQUEST['country']]));
|
||||
}
|
||||
}
|
||||
if ($result) {
|
||||
$tpl->assign('success', sprintf($lang_admin['plzeditor_test_success'],
|
||||
htmlentities(trim($_REQUEST['zip'])),
|
||||
htmlentities(trim($_REQUEST['city'])),
|
||||
$countryList[$_REQUEST['country']]));
|
||||
} else {
|
||||
$tpl->assign('error', sprintf($lang_admin['plzeditor_test_error'],
|
||||
htmlentities(trim($_REQUEST['zip'])),
|
||||
htmlentities(trim($_REQUEST['city'])),
|
||||
$countryList[$_REQUEST['country']]));
|
||||
}
|
||||
} elseif (isset($_REQUEST['do']) && $_REQUEST['do'] == 'add') {
|
||||
$result = $this->_ZIPAdd(trim($_REQUEST['zip']),
|
||||
trim($_REQUEST['city']),
|
||||
(int) $_REQUEST['country']);
|
||||
|
||||
else if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'add')
|
||||
{
|
||||
$result = $this->_ZIPAdd(trim($_REQUEST['zip']),
|
||||
trim($_REQUEST['city']),
|
||||
(int)$_REQUEST['country']);
|
||||
if ($result) {
|
||||
$tpl->assign('success', sprintf($lang_admin['plzeditor_add_success'],
|
||||
htmlentities(trim($_REQUEST['zip'])),
|
||||
htmlentities(trim($_REQUEST['city'])),
|
||||
$countryList[$_REQUEST['country']]));
|
||||
} else {
|
||||
$tpl->assign('error', sprintf($lang_admin['plzeditor_add_error'],
|
||||
'plz/'.(int) $_REQUEST['country'].'.plz'));
|
||||
}
|
||||
}
|
||||
|
||||
if($result)
|
||||
{
|
||||
$tpl->assign('success', sprintf($lang_admin['plzeditor_add_success'],
|
||||
htmlentities(trim($_REQUEST['zip'])),
|
||||
htmlentities(trim($_REQUEST['city'])),
|
||||
$countryList[$_REQUEST['country']]));
|
||||
}
|
||||
else
|
||||
{
|
||||
$tpl->assign('error', sprintf($lang_admin['plzeditor_add_error'],
|
||||
'plz/' . (int)$_REQUEST['country'] . '.plz'));
|
||||
}
|
||||
}
|
||||
$plzFiles = $this->_getPLZFiles();
|
||||
|
||||
$plzFiles = $this->_getPLZFiles();
|
||||
$tpl->assign('pageURL', $this->_adminLink());
|
||||
$tpl->assign('plzFiles', $plzFiles);
|
||||
$tpl->assign('defaultCountryID', $bm_prefs['std_land']);
|
||||
$tpl->assign('page', $this->_templatePath('plzeditor.editor.tpl'));
|
||||
}
|
||||
}
|
||||
|
||||
$tpl->assign('pageURL', $this->_adminLink());
|
||||
$tpl->assign('plzFiles', $plzFiles);
|
||||
$tpl->assign('defaultCountryID', $bm_prefs['std_land']);
|
||||
$tpl->assign('page', $this->_templatePath('plzeditor.editor.tpl'));
|
||||
}
|
||||
}
|
||||
private function _getPLZFiles()
|
||||
{
|
||||
$result = [];
|
||||
$countries = CountryList();
|
||||
$plzDir = B1GMAIL_DIR.'plz/';
|
||||
|
||||
function _getPLZFiles()
|
||||
{
|
||||
$result = array();
|
||||
$countries = CountryList();
|
||||
$plzDir = B1GMAIL_DIR . 'plz/';
|
||||
$d = dir($plzDir);
|
||||
while ($filename = $d->read()) {
|
||||
if (substr($filename, -4) != '.plz') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$d = dir($plzDir);
|
||||
while($filename = $d->read())
|
||||
{
|
||||
if(substr($filename, -4) != '.plz')
|
||||
continue;
|
||||
$countryID = substr($filename, 0, -4);
|
||||
if (isset($countries[$countryID])) {
|
||||
$result[$countryID] = $countries[$countryID];
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
|
||||
$countryID = substr($filename, 0, -4);
|
||||
if(isset($countries[$countryID]))
|
||||
$result[$countryID] = $countries[$countryID];
|
||||
}
|
||||
$d->close();
|
||||
return $result;
|
||||
}
|
||||
|
||||
return($result);
|
||||
}
|
||||
private function _ZIPAdd($plz, $ort, $staat)
|
||||
{
|
||||
if (ZIPCheck($plz, $ort, $staat)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function _ZIPAdd($plz, $ort, $staat)
|
||||
{
|
||||
if(ZIPCheck($plz, $ort, $staat))
|
||||
return(true);
|
||||
$filePath = B1GMAIL_DIR.'plz/'.(int) $staat.'.plz';
|
||||
|
||||
$filePath = B1GMAIL_DIR . 'plz/' . (int)$staat . '.plz';
|
||||
if (!file_exists($filePath) || !is_writeable($filePath)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!file_exists($filePath) || !is_writeable($filePath))
|
||||
return(false);
|
||||
$strip_chars = [',', ';', '-', '?', ':', '?', '1', ' ', 'ä', 'Ä', 'ö', 'Ö', 'ü', 'Ü', 'ae', 'oe', 'ue', 'AE', 'OE', 'UE', 'Ae', 'Oe', 'Ue'];
|
||||
|
||||
$strip_chars = array(',', ';', '-', '?', ':', '?', '1', ' ', 'ä', 'Ä', 'ö', 'Ö', 'ü', 'Ü', "ae", "oe", "ue", "AE", "OE", "UE", "Ae", "Oe","Ue");
|
||||
$plz = preg_replace('/^([0]*)/', '', $plz);
|
||||
$ort = strtolower($ort);
|
||||
$ort = str_replace($strip_chars, '', $ort);
|
||||
$hash = $plz.soundex($ort);
|
||||
$hash = crc32($hash);
|
||||
$hash = pack('i', $hash);
|
||||
|
||||
$plz = preg_replace('/^([0]*)/', '', $plz);
|
||||
$ort = strtolower($ort);
|
||||
$ort = str_replace($strip_chars, '', $ort);
|
||||
$hash = $plz . soundex($ort);
|
||||
$hash = crc32($hash);
|
||||
$hash = pack('i', $hash);
|
||||
$fp = fopen($filePath, 'ab');
|
||||
fwrite($fp, $hash, 4);
|
||||
fclose($fp);
|
||||
|
||||
$fp = fopen($filePath, 'ab');
|
||||
fwrite($fp, $hash, 4);
|
||||
fclose($fp);
|
||||
|
||||
return(true);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* register plugin
|
||||
*/
|
||||
$plugins->registerPlugin('PLZEditorPlugin');
|
||||
?>
|
|
@ -20,7 +20,7 @@
|
|||
*/
|
||||
class RemoveIPPlugin extends BMPlugin
|
||||
{
|
||||
function __construct()
|
||||
public function __construct()
|
||||
{
|
||||
$this->type = BMPLUGIN_DEFAULT;
|
||||
$this->name = 'RemoveIP Plugin';
|
||||
|
@ -28,7 +28,7 @@ class RemoveIPPlugin extends BMPlugin
|
|||
$this->version = '1.0.0';
|
||||
}
|
||||
|
||||
function AfterInit()
|
||||
public function AfterInit()
|
||||
{
|
||||
global $bm_prefs;
|
||||
|
||||
|
@ -42,5 +42,4 @@ class RemoveIPPlugin extends BMPlugin
|
|||
}
|
||||
}
|
||||
|
||||
$plugins->registerPlugin('RemoveIPPlugin');
|
||||
?>
|
||||
$plugins->registerPlugin('RemoveIPPlugin');
|
|
@ -20,16 +20,13 @@
|
|||
*/
|
||||
|
||||
/**
|
||||
* whitelist plugin
|
||||
*
|
||||
* whitelist plugin.
|
||||
*/
|
||||
class WhitelistPlugin extends BMPlugin
|
||||
{
|
||||
function __construct()
|
||||
{
|
||||
global $lang_admin;
|
||||
|
||||
// plugin info
|
||||
public function __construct()
|
||||
{
|
||||
// plugin info
|
||||
$this->type = BMPLUGIN_DEFAULT;
|
||||
$this->name = 'Whitelist';
|
||||
$this->author = 'b1gMail Project';
|
||||
|
@ -37,59 +34,58 @@ class WhitelistPlugin extends BMPlugin
|
|||
$this->mail = 'info@b1gmail.org';
|
||||
$this->version = '1.1';
|
||||
|
||||
// group option
|
||||
$this->RegisterGroupOption('whitelist',
|
||||
FIELD_CHECKBOX,
|
||||
'Whitelist?');
|
||||
}
|
||||
// group option
|
||||
$this->RegisterGroupOption('whitelist',
|
||||
FIELD_CHECKBOX,
|
||||
'Whitelist?');
|
||||
}
|
||||
|
||||
function OnReceiveMail(&$mail, &$mailbox, &$user)
|
||||
{
|
||||
global $db;
|
||||
public function OnReceiveMail(&$mail, &$mailbox, &$user)
|
||||
{
|
||||
global $db;
|
||||
|
||||
// check input data
|
||||
if(!is_object($mail) || !is_object($user))
|
||||
{
|
||||
PutLog('WhitelistPlugin: $mail or $user invalid', PRIO_DEBUG, __FILE__, __LINE__);
|
||||
return(BM_OK);
|
||||
}
|
||||
// check input data
|
||||
if (!is_object($mail) || !is_object($user)) {
|
||||
PutLog('WhitelistPlugin: $mail or $user invalid', PRIO_DEBUG, __FILE__, __LINE__);
|
||||
|
||||
// check if whitelist is enabled for user's group
|
||||
$userGroupID = $user->_row['gruppe'];
|
||||
if(!$this->GetGroupOptionValue('whitelist', $userGroupID))
|
||||
return(BM_OK);
|
||||
return BM_OK;
|
||||
}
|
||||
|
||||
// lookup sender addresses in addressbook
|
||||
$from = ExtractMailAddresses($mail->GetHeaderValue('from'));
|
||||
$res = $db->Query('SELECT COUNT(*) FROM {pre}adressen WHERE `user`=? AND (`email` IN ? OR `work_email` IN ?)',
|
||||
$user->_id,
|
||||
$from,
|
||||
$from);
|
||||
list($addressBookEntryCount) = $res->FetchArray(MYSQLI_NUM);
|
||||
$res->Free();
|
||||
// check if whitelist is enabled for user's group
|
||||
$userGroupID = $user->_row['gruppe'];
|
||||
if (!$this->GetGroupOptionValue('whitelist', $userGroupID)) {
|
||||
return BM_OK;
|
||||
}
|
||||
|
||||
// return
|
||||
if($addressBookEntryCount > 0)
|
||||
{
|
||||
PutLog(sprintf('WhitelistPlugin: Accepted email for user #%d', $user->_id),
|
||||
PRIO_DEBUG,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
return(BM_OK);
|
||||
}
|
||||
else
|
||||
{
|
||||
PutLog(sprintf('WhitelistPlugin: Rejected email for user #%d', $user->_id),
|
||||
PRIO_DEBUG,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
return(BM_BLOCK);
|
||||
}
|
||||
}
|
||||
// lookup sender addresses in addressbook
|
||||
$from = ExtractMailAddresses($mail->GetHeaderValue('from'));
|
||||
$res = $db->Query('SELECT COUNT(*) FROM {pre}adressen WHERE `user`=? AND (`email` IN ? OR `work_email` IN ?)',
|
||||
$user->_id,
|
||||
$from,
|
||||
$from);
|
||||
list($addressBookEntryCount) = $res->FetchArray(MYSQLI_NUM);
|
||||
$res->Free();
|
||||
|
||||
// return
|
||||
if ($addressBookEntryCount > 0) {
|
||||
PutLog(sprintf('WhitelistPlugin: Accepted email for user #%d', $user->_id),
|
||||
PRIO_DEBUG,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
|
||||
return BM_OK;
|
||||
} else {
|
||||
PutLog(sprintf('WhitelistPlugin: Rejected email for user #%d', $user->_id),
|
||||
PRIO_DEBUG,
|
||||
__FILE__,
|
||||
__LINE__);
|
||||
|
||||
return BM_BLOCK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
* register plugin
|
||||
*/
|
||||
$plugins->registerPlugin('WhitelistPlugin');
|
||||
?>
|
|
@ -852,7 +852,9 @@ function HTMLFormat($in, $allowDoubleEncoding = false, $allowEncodingRepair = tr
|
|||
|
||||
if($allowEncodingRepair && strlen($in) > 0 && strlen($res) == 0 && function_exists('mb_detect_encoding'))
|
||||
{
|
||||
$in = @mb_convert_encoding($in, $currentCharset, mb_detect_encoding($in));
|
||||
$fromEncoding = mb_detect_encoding($in); //FIXME: Better detection of invalid Encoding
|
||||
if($fromEncoding === FALSE) $fromEncoding='UTF-8'; // Uncaught ValueError: mb_convert_encoding(): Argument #3 ($from_encoding) must specify at least one encoding
|
||||
$in = @mb_convert_encoding($in, $currentCharset, $fromEncoding);
|
||||
return(HTMLFormat($in, $allowDoubleEncoding, false));
|
||||
}
|
||||
|
||||
|
@ -1901,7 +1903,7 @@ function formatEMailText($in, $html = true, $mobile = false)
|
|||
foreach($bmLinks as $i=>$link)
|
||||
{
|
||||
$in = str_replace(sprintf(':::_b1gMailLink:%d_:::', $i),
|
||||
sprintf('<a href="deref.php?%s" target="_blank" rel="noopener noreferrer">%s</a>', $link, $link),
|
||||
sprintf('<a href="deref.php?%s" title="%s" target="_blank" rel="noopener noreferrer">%s</a>', $link, $link, $link),
|
||||
$in);
|
||||
}
|
||||
}
|
||||
|
@ -2691,7 +2693,9 @@ function ZIPCheck($plz, $ort, $staat)
|
|||
if(file_exists($plzfile))
|
||||
{
|
||||
$fp = fopen($plzfile, 'r');
|
||||
$inh = fread($fp, filesize($plzfile));
|
||||
$plz_filesize = filesize($plzfile);
|
||||
if ($plz_filesize == 0) return(false);
|
||||
$inh = fread($fp, $plz_filesize);
|
||||
fclose($fp);
|
||||
|
||||
$pos = strpos($inh, $hash); # In der PLZ-Datei nach dem PLZ/Ort-Paar suchen
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue