remove obsolete koobi7 and jfchat plugin

This commit is contained in:
Sebijk 2023-02-01 20:15:05 +01:00
parent c8f5e7b2cf
commit db1d099341
5 changed files with 0 additions and 723 deletions

View file

@ -1,299 +0,0 @@
<?php
/*
* b1gMail jfChat auth plugin
* (c) 2021 Patrick Schlangen et al
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/**
* jfChat plugin
*
*/
class jfChatAuthPlugin extends BMPlugin
{
var $_uidFormat = 'jfC:%s';
/**
* constructor
*
* @return jfChatAuthPlugin
*/
function __construct()
{
// plugin info
$this->type = BMPLUGIN_DEFAULT;
$this->name = 'jfChat Authentication Plugin';
$this->author = 'b1gMail Project';
$this->web = 'https://www.b1gmail.org/';
$this->mail = 'info@b1gmail.org';
$this->version = '1.2';
// admin pages
$this->admin_pages = true;
$this->admin_page_title = 'jfChat-Auth';
}
/**
* get list of domains
*
* @return array
*/
private function _getDomains()
{
global $bm_prefs;
if(function_exists('GetDomainList'))
return GetDomainList();
else
return explode(':', $bm_prefs['domains']);
}
/**
* installation routine
*
* @return bool
*/
function Install()
{
global $db, $bm_prefs;
// create prefs table
$db->Query('CREATE TABLE {pre}jfchat_plugin_prefs(enableAuth tinyint(4) NOT NULL DEFAULT 0, mysqlHost varchar(128) NOT NULL, mysqlUser varchar(128) NOT NULL, mysqlPass varchar(128) NOT NULL, mysqlDB varchar(128) NOT NULL, mysqlPrefix varchar(128) NOT NULL, userDomain varchar(128) NOT NULL)');
// insert initial row
list($domain) = explode(':', $bm_prefs['domains']);
$db->Query('REPLACE INTO {pre}jfchat_plugin_prefs(enableAuth, mysqlHost, mysqlUser, mysqlPass, mysqlDB, mysqlPrefix, userDomain) VALUES'
. '(?,?,?,?,?,?,?)',
0,
'localhost',
'jfchat-user',
'password',
'jfchat',
'fwc_',
$domain);
return(true);
}
/**
* uninstallation routine
*
* @return bool
*/
function Uninstall()
{
global $db;
// drop prefs table
$db->Query('DROP TABLE {pre}jfchat_plugin_prefs');
return(true);
}
/**
* authentication handler
*
* @param string $userName
* @param string $userDomain
* @param string $passwordMD5
* @return array
*/
function OnAuthenticate($userName, $userDomain, $passwordMD5, $passwordPlain = '')
{
global $db, $bm_prefs;
// get config
$res = $db->Query('SELECT * FROM {pre}jfchat_plugin_prefs LIMIT 1');
$jfchat_prefs = $res->FetchArray();
$res->Free();
// enabled?
if($jfchat_prefs['enableAuth'] != 1)
return(false);
// our domain?
if(strtolower($userDomain) != strtolower($jfchat_prefs['userDomain']))
return(false);
// connect to jfChat DB
$mysql = @mysqli_connect($jfchat_prefs['mysqlHost'], $jfchat_prefs['mysqlUser'], $jfchat_prefs['mysqlPass'], true);
if($mysql)
{
if(mysqli_select_db($jfchat_prefs['mysqlDB'], $mysql))
{
$jfchatDB = new DB($mysql);
// search user
$res = $jfchatDB->Query('SELECT `username`,`password`,`emailadresse`,`wohnort` FROM ' . $jfchat_prefs['mysqlPrefix'] . 'registry WHERE `username`=?',
$userName);
if($res->RowCount() == 0)
return(false);
$row = $res->FetchArray(MYSQLI_ASSOC);
$res->Free();
// check password
if($row['password'] === $passwordMD5)
{
$uid = sprintf($this->_uidFormat, $row['username']);
$myUserName = sprintf('%s@%s', $userName, $userDomain);
// create user in b1gMail?
if(BMUser::GetID($myUserName) == 0)
{
PutLog(sprintf('Creating b1gMail user for jfChat user <%s>',
$userName),
PRIO_PLUGIN,
__FILE__,
__LINE__);
$bmUID = BMUser::CreateAccount($myUserName,
'',
'',
'',
'',
'',
$row['wohnort'],
$bm_prefs['std_land'],
'',
'',
$row['emailadresse'],
'',
$passwordMD5,
array(),
true,
$uid);
}
// return
$result = array(
'uid' => $uid,
'profile' => array(
'altmail' => $row['emailadresse'],
'ort' => $row['wohnort']
)
);
return($result);
}
else
return(false);
}
else
PutLog('Failed to select jfChat db',
PRIO_PLUGIN,
__FILE__,
__LINE__);
unset($jfchatDB);
mysqli_close($mysql);
}
else
PutLog('MySQL connection to jfChat db failed',
PRIO_PLUGIN,
__FILE__,
__LINE__);
return(false);
}
/**
* user page handler
*
*/
function FileHandler($file, $action)
{
global $userRow;
if(!isset($userRow) || !is_array($userRow))
return(false);
if(strpos($userRow['uid'], substr($this->_uidFormat, 0, strpos($this->_uidFormat, ':')+1)) === false || $userRow['vorname'] != '' || $userRow['nachname'] != '')
return(false);
$file = strtolower($file);
$action = strtolower($action);
if($file != 'index.php' && ($file != 'prefs.php' || $action != 'contact')
&& ($file != 'start.php' || $action != 'logout'))
{
header('Location: prefs.php?action=contact&sid=' . session_id());
exit();
}
}
/**
* admin handler
*
*/
function AdminHandler()
{
global $tpl, $plugins, $lang_admin;
if(!isset($_REQUEST['action']))
$_REQUEST['action'] = 'prefs';
$tabs = array(
0 => array(
'title' => $lang_admin['prefs'],
'link' => $this->_adminLink() . '&',
'active' => $_REQUEST['action'] == 'prefs'
)
);
$tpl->assign('tabs', $tabs);
if($_REQUEST['action'] == 'prefs')
$this->_prefsPage();
}
/**
* admin prefs page
*
*/
function _prefsPage()
{
global $tpl, $db, $bm_prefs;
// save?
if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'save')
{
$db->Query('UPDATE {pre}jfchat_plugin_prefs SET enableAuth=?,mysqlHost=?,mysqlUser=?,mysqlPass=?,mysqlDB=?,mysqlPrefix=?,userDomain=?',
isset($_REQUEST['enableAuth']) ? 1 : 0,
$_REQUEST['mysqlHost'],
$_REQUEST['mysqlUser'],
$_REQUEST['mysqlPass'],
$_REQUEST['mysqlDB'],
$_REQUEST['mysqlPrefix'],
trim($_REQUEST['userDomain']));
}
// get config
$res = $db->Query('SELECT * FROM {pre}jfchat_plugin_prefs LIMIT 1');
$jfchat_prefs = $res->FetchArray();
$res->Free();
// assign
$tpl->assign('domains', $this->_getDomains());
$tpl->assign('jfchat_prefs', $jfchat_prefs);
$tpl->assign('pageURL', $this->_adminLink());
$tpl->assign('page', $this->_templatePath('jfchatauth.plugin.prefs.tpl'));
}
}
/**
* register plugin
*/
$plugins->registerPlugin('jfChatAuthPlugin');
?>

View file

@ -1,332 +0,0 @@
<?php
/*
* b1gMail koobi 7 auth plugin
* (c) 2021 Patrick Schlangen et al
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
/**
* Koobi 7 auth plugin
*
*/
class Koobi7AuthPlugin extends BMPlugin
{
var $_uidFormat = 'K7:%d';
/**
* constructor
*
* @return Koobi7AuthPlugin
*/
function __construct()
{
// plugin info
$this->type = BMPLUGIN_DEFAULT;
$this->name = 'Koobi7 Authentication Plugin';
$this->author = 'b1gMail Project';
$this->web = 'https://www.b1gmail.org/';
$this->mail = 'ps@b1g.de';
$this->version = '1.2';
// admin pages
$this->admin_pages = true;
$this->admin_page_title = 'Koobi7-Auth';
$this->admin_page_icon = "koobi32.png";
}
/**
* get list of domains
*
* @return array
*/
private function _getDomains()
{
global $bm_prefs;
if(function_exists('GetDomainList'))
return GetDomainList();
else
return explode(':', $bm_prefs['domains']);
}
/**
* installation routine
*
* @return bool
*/
function Install()
{
global $db, $bm_prefs;
// create prefs table
$db->Query('CREATE TABLE {pre}koobi7_plugin_prefs(enableAuth tinyint(4) NOT NULL DEFAULT 0, mysqlHost varchar(128) NOT NULL, mysqlUser varchar(128) NOT NULL, mysqlPass varchar(128) NOT NULL, mysqlDB varchar(128) NOT NULL, mysqlPrefix varchar(128) NOT NULL, userDomain varchar(128) NOT NULL)');
// insert initial row
list($domain) = explode(':', $bm_prefs['domains']);
$db->Query('REPLACE INTO {pre}koobi7_plugin_prefs(enableAuth, mysqlHost, mysqlUser, mysqlPass, mysqlDB, mysqlPrefix, userDomain) VALUES'
. '(?,?,?,?,?,?,?)',
0,
'localhost',
'koobi7-user',
'password',
'koobi7',
'koobi7_',
$domain);
return(true);
}
/**
* uninstallation routine
*
* @return bool
*/
function Uninstall()
{
global $db;
// drop prefs table
$db->Query('DROP TABLE {pre}koobi7_plugin_prefs');
return(true);
}
/**
* authentication handler
*
* @param string $userName
* @param string $userDomain
* @param string $passwordMD5
* @return array
*/
function OnAuthenticate($userName, $userDomain, $passwordMD5, $passwordPlain = '')
{
global $db, $bm_prefs;
// get config
$res = $db->Query('SELECT * FROM {pre}koobi7_plugin_prefs LIMIT 1');
$koobi7_prefs = $res->FetchArray();
$res->Free();
// enabled?
if($koobi7_prefs['enableAuth'] != 1)
return(false);
// our domain?
if(strtolower($userDomain) != strtolower($koobi7_prefs['userDomain']))
return(false);
// connect to koobi7 DB
$mysql = @mysqli_connect($koobi7_prefs['mysqlHost'], $koobi7_prefs['mysqlUser'], $koobi7_prefs['mysqlPass'], true);
if($mysql)
{
if(mysqli_select_db($koobi7_prefs['mysqlDB'], $mysql))
{
$koobi7DB = new DB($mysql);
// search user
$res = $koobi7DB->Query('SELECT `Id`,`Kennwort`,`Email`,`Vorname`,`Nachname`,`Strasse_Nr`,`Postleitzahl`,`Ort`,`Telefon`,`Telefax`,`Land` FROM ' . $koobi7_prefs['mysqlPrefix'] . 'benutzer WHERE `Benutzername`=? AND `Aktiv`=1',
$userName);
if($res->RowCount() == 0)
return(false);
$row = $res->FetchArray(MYSQLI_ASSOC);
$res->Free();
// check password
if(md5($passwordMD5) === $row['Kennwort'])
{
$uid = sprintf($this->_uidFormat, $row['Id']);
$myUserName = sprintf('%s@%s', $userName, $userDomain);
// split street/no
$strasseNrParts = explode(' ', $row['Strasse_Nr']);
if(count($strasseNrParts) > 1)
{
$no = array_pop($strasseNrParts);
$street = implode(' ', $strasseNrParts);
}
else
{
$street = $row['Strasse_Nr'];
$no = '';
}
// find country
$countries = CountryList();
$country = $bm_prefs['std_land'];
foreach($countries as $countryID=>$countryName)
if($countryName == $row['Land'])
{
$country = $countryID;
break;
}
// create user in b1gMail?
if(BMUser::GetID($myUserName) == 0)
{
PutLog(sprintf('Creating b1gMail user for Koobi7 user <%s> (%d)',
$userName,
$row['Id']),
PRIO_PLUGIN,
__FILE__,
__LINE__);
$bmUID = BMUser::CreateAccount($myUserName,
$row['Vorname'],
$row['Nachname'],
$street,
$no,
$row['Postleitzahl'],
$row['Ort'],
$country,
$row['Telefon'],
$row['Telefax'],
$row['Email'],
'',
$passwordMD5,
array(),
true,
$uid);
}
// return
$result = array(
'uid' => $uid,
'profile' => array(
'altmail' => $row['Email'],
'vorname' => $row['Vorname'],
'nachname' => $row['Nachname'],
'strasse' => $street,
'hnr' => $no,
'plz' => $row['Postleitzahl'],
'ort' => $row['Ort'],
'land' => $country,
'tel' => $row['Telefon'],
'fax' => $row['Telefax']
)
);
return($result);
}
else
return(false);
}
else
PutLog('Failed to select koobi7 db',
PRIO_PLUGIN,
__FILE__,
__LINE__);
unset($koobi7DB);
mysqli_close($mysql);
}
else
PutLog('MySQL connection to koobi7 db failed',
PRIO_PLUGIN,
__FILE__,
__LINE__);
return(false);
}
/**
* user page handler
*
*/
function FileHandler($file, $action)
{
global $userRow;
if(!isset($userRow) || !is_array($userRow))
return(false);
if(strpos($userRow['uid'], substr($this->_uidFormat, 0, strpos($this->_uidFormat, ':')+1)) === false || $userRow['vorname'] != '' || $userRow['nachname'] != '')
return(false);
$file = strtolower($file);
$action = strtolower($action);
if($file != 'index.php' && ($file != 'prefs.php' || $action != 'contact')
&& ($file != 'start.php' || $action != 'logout'))
{
header('Location: prefs.php?action=contact&sid=' . session_id());
exit();
}
}
/**
* admin handler
*
*/
function AdminHandler()
{
global $tpl, $plugins, $lang_admin;
if(!isset($_REQUEST['action']))
$_REQUEST['action'] = 'prefs';
$tabs = array(
0 => array(
'title' => $lang_admin['prefs'],
'link' => $this->_adminLink() . '&',
'active' => $_REQUEST['action'] == 'prefs'
)
);
$tpl->assign('tabs', $tabs);
if($_REQUEST['action'] == 'prefs')
$this->_prefsPage();
}
/**
* admin prefs page
*
*/
function _prefsPage()
{
global $tpl, $db, $bm_prefs;
// save?
if(isset($_REQUEST['do']) && $_REQUEST['do'] == 'save')
{
$db->Query('UPDATE {pre}koobi7_plugin_prefs SET enableAuth=?,mysqlHost=?,mysqlUser=?,mysqlPass=?,mysqlDB=?,mysqlPrefix=?,userDomain=?',
isset($_REQUEST['enableAuth']) ? 1 : 0,
$_REQUEST['mysqlHost'],
$_REQUEST['mysqlUser'],
$_REQUEST['mysqlPass'],
$_REQUEST['mysqlDB'],
$_REQUEST['mysqlPrefix'],
trim($_REQUEST['userDomain']));
}
// get config
$res = $db->Query('SELECT * FROM {pre}koobi7_plugin_prefs LIMIT 1');
$koobi7_prefs = $res->FetchArray();
$res->Free();
// assign
$tpl->assign('domains', $this->_getDomains());
$tpl->assign('koobi7_prefs', $koobi7_prefs);
$tpl->assign('pageURL', $this->_adminLink());
$tpl->assign('page', $this->_templatePath('koobi7auth.plugin.prefs.tpl'));
}
}
/**
* register plugin
*/
$plugins->registerPlugin('Koobi7AuthPlugin');
?>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 640 B

View file

@ -1,46 +0,0 @@
<fieldset>
<legend>{lng p="prefs"}</legend>
<form action="{$pageURL}&sid={$sid}&do=save" method="post" onsubmit="spin(this)">
<table>
<tr>
<td align="left" rowspan="7" valign="top" width="40"><img src="../plugins/templates/images/jfchat32.png" border="0" alt="" width="32" height="32" /></td>
<td class="td1" width="160">{lng p="enable"}?</td>
<td class="td2"><input name="enableAuth"{if $jfchat_prefs.enableAuth} checked="checked"{/if} type="checkbox" /></td>
</tr>
<tr>
<td class="td1">MySQL {lng p="host"}:</td>
<td class="td2"><input type="text" name="mysqlHost" value="{if isset($jfchat_prefs.mysqlHost)}{text value=$jfchat_prefs.mysqlHost}{/if}" size="36" /></td>
</tr>
<tr>
<td class="td1">MySQL {lng p="user"}:</td>
<td class="td2"><input type="text" name="mysqlUser" value="{if isset($jfchat_prefs.mysqlUser)}{text value=$jfchat_prefs.mysqlUser}{/if}" size="36" /></td>
</tr>
<tr>
<td class="td1">MySQL {lng p="password"}:</td>
<td class="td2"><input type="password" name="mysqlPass" value="{if isset($jfchat_prefs.mysqlPass)}{text value=$jfchat_prefs.mysqlPass}{/if}" size="36" /></td>
</tr>
<tr>
<td class="td1">MySQL {lng p="db"}:</td>
<td class="td2"><input type="text" name="mysqlDB" value="{if isset($jfchat_prefs.mysqlDB)}{text value=$jfchat_prefs.mysqlDB}{/if}" size="36" /></td>
</tr>
<tr>
<td class="td1">MySQL Prefix:</td>
<td class="td2"><input type="text" name="mysqlPrefix" value="{if isset($jfchat_prefs.mysqlPrefix)}{text value=$jfchat_prefs.mysqlPrefix allowEmpty=true}{/if}" size="36" /></td>
</tr>
<tr>
<td class="td1">{lng p="user"}-{lng p="domain"}:</td>
<td class="td2"><select name="userDomain">
{foreach from=$domains item=domain}
<option value="{$domain}"{if $jfchat_prefs.userDomain==$domain} selected="selected"{/if}>{$domain}</option>
{/foreach}
</select></td>
</tr>
</table>
<p>
<div style="float:right;">
<input class="button" type="submit" value=" {lng p="save"} " />
</div>
</p>
</form>
</fieldset>

View file

@ -1,46 +0,0 @@
<fieldset>
<legend>{lng p="prefs"}</legend>
<form action="{$pageURL}&sid={$sid}&do=save" method="post" onsubmit="spin(this)">
<table>
<tr>
<td align="left" rowspan="7" valign="top" width="40"><img src="../plugins/templates/images/koobi32.png" border="0" alt="" width="32" height="32" /></td>
<td class="td1" width="160">{lng p="enable"}?</td>
<td class="td2"><input name="enableAuth"{if $koobi7_prefs.enableAuth} checked="checked"{/if} type="checkbox" /></td>
</tr>
<tr>
<td class="td1">MySQL {lng p="host"}:</td>
<td class="td2"><input type="text" name="mysqlHost" value="{if isset($koobi7_prefs.mysqlHost)}{text value=$koobi7_prefs.mysqlHost}{/if}" size="36" /></td>
</tr>
<tr>
<td class="td1">MySQL {lng p="user"}:</td>
<td class="td2"><input type="text" name="mysqlUser" value="{if isset($koobi7_prefs.mysqlUser)}{text value=$koobi7_prefs.mysqlUser}{/if}" size="36" /></td>
</tr>
<tr>
<td class="td1">MySQL {lng p="password"}:</td>
<td class="td2"><input type="password" name="mysqlPass" value="{if isset($koobi7_prefs.mysqlPass)}{text value=$koobi7_prefs.mysqlPass}{/if}" size="36" /></td>
</tr>
<tr>
<td class="td1">MySQL {lng p="db"}:</td>
<td class="td2"><input type="text" name="mysqlDB" value="{if isset($koobi7_prefs.mysqlDB)}{text value=$koobi7_prefs.mysqlDB}{/if}" size="36" /></td>
</tr>
<tr>
<td class="td1">MySQL Prefix:</td>
<td class="td2"><input type="text" name="mysqlPrefix" value="{if isset($koobi7_prefs.mysqlPrefix)}{text value=$koobi7_prefs.mysqlPrefix allowEmpty=true}{/if}" size="36" /></td>
</tr>
<tr>
<td class="td1">{lng p="user"}-{lng p="domain"}:</td>
<td class="td2"><select name="userDomain">
{foreach from=$domains item=domain}
<option value="{$domain}"{if $koobi7_prefs.userDomain==$domain} selected="selected"{/if}>{$domain}</option>
{/foreach}
</select></td>
</tr>
</table>
<p>
<div style="float:right;">
<input class="button" type="submit" value=" {lng p="save"} " />
</div>
</p>
</form>
</fieldset>