Initial commit

This commit is contained in:
genuineparts 2025-06-02 10:01:12 +02:00
commit 43ad32700c
7085 changed files with 447606 additions and 0 deletions

View file

@ -0,0 +1,137 @@
<?php
/**
* Project: astat - simple site engine
* File: /modules/mybb/admin.apnl.php
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.astat.org SVN: $URL$
* @copyright 2010 becast.at
* @author Bernhard Jaud <bernhard at becast dot at>
* @package astat module
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
*/
If (!defined("in_BL_ADMIN")) {
die("Dieses Script kann nicht ausserhalb des Frameworks laufen!");
}
$session->page_begin("mybb admin", True);
class admin_mybb_panel extends admin_module{
function output(){
global $config, $db,$panel, $cache, $session;
if(isset($_POST['submit'])){
if(isset($_POST['prefix'])&& $_POST['prefix']!=""){
$cf3cfg=array('prefix'=>$_POST['prefix']);
$cache->set('mybbconfig',$cf3cfg);
$panel->admin_message('Danke', 'Prefix wurde eingetragen!',TRUE,'admin_mybb');
}
}elseif(isset($_POST['insert'])){
$cf3cfg=array('prefix'=>$_POST['prefix']);
$res=$db->query('SELECT * FROM `'.$config['prefix'].'users`');
$this->cf3_conf=$this->fetchboardconfig();
while($row=$db->fetch_array($res)){
if($row['uid']==$session->userdata['uid']){
$db->query("UPDATE `" . $config['prefix'] . "users` SET `fuid`='1' WHERE `uid`='".$row['uid']."'");
continue;
}
$salt = $session->generate_Key(32);
$saltetpass = md5($row['password'].$salt);
$user_update['user_perm_grp'] = ($this->cf3_conf['reg_default_group'] <= 0)? 1 : $this->cf3_conf['reg_default_group'];
$user_update['user_topics_per_page'] = $this->cf3_conf['topics_per_page'];
$user_update['user_posts_per_page'] = $this->cf3_conf['posts_per_page'];
$user_update['user_dateformat'] = $this->cf3_conf['def_timeformat'];
$user_update['user_realname'] = $row['realname'];
$user_update['user_from'] = $row['from'];
$user_update['user_birthday'] = $row['birthday'];
$user_update['user_allow_pm'] = 1;
$user_update['user_activate_smilies'] = 1;
$user_update['user_activate_sig'] = 1;
$user_update['user_activate_bbcode'] = 1;
$user_update['user_show_pm_new'] = 1;
$user_update['user_auto_abo'] = 1;
$user_update['user_abo_type'] = 0;
$user_update['user_show_sigs'] = 1;
$user_update['user_show_avatars'] = 1;
$user_update['user_show_images'] = 1;
$user_update['user_show_embed_bbcode'] = 1;
$user_update['user_show_smilies'] = 1;
$user_update['user_show_pm_new_snd'] = 1;
if($row['gender'] == 'm'){
$user_update['user_gender']=1;
}elseif($rdata['gender'] == 'f'){
$user_update['user_gender']=2;
}else{
$user_update['user_gender']=0;
}
$db->query("INSERT INTO `" . $cf3cfg['prefix'] . "users` (`user_nickname`,`user_salt`,`user_password`,`user_old_pw`,`user_registered_since`,`user_email`,`user_perm_grp`,`user_actkey`,`user_active`,`user_topics_per_page`,`user_posts_per_page`,`user_dateformat`,`user_gender`,`user_realname`,`user_birthday`,`user_allow_pm`,`user_activate_smilies`,`user_activate_sig`,`user_activate_bbcode`,`user_show_pm_new`,`user_auto_abo`,`user_abo_type`,`user_show_sigs`,`user_show_avatars`,`user_show_images`,`user_show_embed_bbcode`,`user_show_smilies`,`user_show_pm_new_snd`,`user_color`,`user_from`)
VALUES ('".$row['username']."','".$salt."','".$saltetpass."',0,'".time()."','".$row['email']."','".$user_update['user_perm_grp']."','".$session->generate_Key(30)."','1','".$user_update['user_topics_per_page']."','".$user_update['user_posts_per_page']."','".$user_update['user_dateformat']."','".$user_update['user_gender']."','".$user_update['user_realname']."','".$user_update['user_birthday']."','".$user_update['user_allow_pm']."','".$user_update['user_activate_smilies']."','".$user_update['user_activate_sig']."','".$user_update['user_activate_bbcode']."','".$user_update['user_show_pm_new']."','".$user_update['user_auto_abo']."','".$user_update['user_abo_type']."','".$user_update['user_show_sigs']."','".$user_update['user_show_avatars']."','".$user_update['user_show_images']."','".$user_update['user_show_embed_bbcode']."','".$user_update['user_show_smilies']."','".$user_update['user_show_pm_new_snd']."','".$user_update['user_color']."','".$user_update['user_from']."')") or die($db->error());
$lid=$db->last_id();
$db->query("UPDATE `" . $config['prefix'] . "users` SET `fuid`='".$lid."' WHERE `uid`='".$row['uid']."'");
$cf3cfg=array('prefix'=>$cf3cfg['prefix'],'installed'=>true);
$cache->set('cf3config',$cf3cfg);
$panel->admin_message('Danke', 'Die Datenbanken wurden verkn&uuml;pft!',TRUE,'admin_mybb');
}
}else{
$count=false;
$cf=$cache->read('mybbconfig');
$panel->title="myBB Forenanbindung verwalten";
$panel->form(array('action'=>$config['path'].'/admin/index.php?panel=admin_mybb'));
$res=$db->query('SELECT count(`uid`) as `count` FROM `'.$cf['prefix'].'users`');
if($res){
$count=$db->fetch_row($res);
$count=$count[0];
}
if($cf['installed']==true){
$panel->content.='<div style="color:green;">Die Forendatenbank wurde erfolgreich verkn&uuml;pft.</div>';
}else{
if($count===false){
$panel->content.='<div style="color:red;">Die Forendatenbank wurde nicht gefunden.</div>';
}elseif($count<=2){
$panel->content.='<div style="color:green;">Die Forendatenbank wurde gefunden. Es kann nun eine Verkn&uuml;pfung vorgenommen werden.</div>';
$panel->submit(array('name'=>'insert'),'value="Daten &uuml;bernehmen"');
}elseif($count>2){
$panel->content.='<div style="color:orange;">Die Forendatenbank wurde gefunden. Es sind aber schon User in der Forendatenbank. Die Verkn&uuml;pfung muss manuell erfolgen.</div>';
}
}
$panel->content.='<h3>Forenprefix:</h3>';
$panel->field(array('name'=>'prefix','typ'=>'text','value'=>$cf['prefix']));
$panel->field(array('name'=>'send','typ'=>'hidden','value'=>'1'));
$panel->submit();
$panel->formClose();
}
}
function fetchboardconfig(){
global $db, $config, $cache, $log;
$mybb=$cache->read('mybbconfig');
try{
$result = $db->query("SELECT `name`, `value` FROM " . $mybb['prefix'] . "settings");
if(!$result){
throw new Exception($db->error());
}
while ($row = $db->fetch_array($result)){
$boardconfig[$row['name']] = $row['value'];
}
$boardconfig['prefix']=$mybb['prefix'];
return $boardconfig;
}catch(Exception $e){
$log->write($e,2,__LINE__,__FILE__);
return NULL;
}
}
}
?>

View file

@ -0,0 +1,35 @@
<?php
class module_mybb extends admin_module{
function admin_panels(){
$panels=array(array("admin_mybb","Forenanbindung","connect"));
return $panels;
}
function get_info(){
$info["name"]="Mybb Bridge";
$info["file"]="mybb";
$info["author"]="BeCast";
$info["version"]="0.5.1";
$info["url"]="http://www.becast.at";
return $info;
}
function install(){
global $config, $db;
$db->query("ALTER TABLE `" . $config["prefix"] . "users` ADD `fuid` INT NOT NULL ,
ADD INDEX ( fuid ) ");
return TRUE;
}
function uninstall(){
global $config, $db;
$db->query("ALTER TABLE `" . $config["prefix"] . "users` DROP `fuid`");
return TRUE;
}
}
?>

View file

@ -0,0 +1,207 @@
<?php
/**
* Project: astat - simple site engine
* File: /modules/mybb_bridge/mybb_bridge.plugins.php
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.astat.org SVN: $URL$
* @copyright 2009 becast.at
* @author Bernhard Jaud <bernhard at becast dot at>
* @package astat core
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id$
*/
If (!defined("in_astat")) {
die("Dieses Script kann nicht ausserhalb des Frameworks laufen!");
}
class plugins_mybb {
private $mybb_conf = array();
function __construct(){
$this->mybb_conf = $this->fetchboardconfig();
}
function register_plugins(& $plugin){
$plugin->use_hook('admin_user_before_delete',array($this,"delete"));
$plugin->use_hook('login_end',array($this,"login"));
$plugin->use_hook('login_openid_end',array($this,"login"));
$plugin->use_hook('register_openid_login',array($this,"login"));
$plugin->use_hook('register_end',array($this,"register"));
$plugin->use_hook('register_openid_end',array($this,"register"));
$plugin->use_hook('logout_end',array($this,"logout"));
$plugin->use_hook('lostpass_mail_pw',array($this,"lostpwd"));
$plugin->use_hook('usercp_end',array($this,"usercp"));
$plugin->use_hook('admin_user_after_update',array($this,"update"));
$plugin->use_hook('admin_user_after_create',array($this,"add"));
}
function login($pdata){
global $db, $config, $session;
$resultf = $db->query("SELECT fu.`loginkey`, fu.`uid` FROM `" . $config["prefix"] . "users` u LEFT JOIN `" . $this->mybb_conf["prefix"] . "users` fu ON fu.`uid`=u.`fuid` WHERE u.`uid`='" . $pdata["uid"] . "' LIMIT 1");
$fud=$db->fetch_array($resultf); //fear, uncertainty and doubt
if($pdata["remember"]=="on"){
$session->setcookie($this->mybb_conf["cookieprefix"]."mybbuser", $fud['uid']."_".$fud['loginkey'],time() + 60 * 60 * 24 * 365,$this->mybb_conf["cookiepath"],$this->mybb_conf['cookiedomain'],true,true);
}else{
$session->setcookie($this->mybb_conf["cookieprefix"]."mybbuser", $fud['uid']."_".$fud['loginkey'],0,$this->mybb_conf["cookiepath"],$this->mybb_conf['cookiedomain'],true,true);
}
}
function logout($ldata){
global $db, $config, $session;
$session->setcookie($this->mybb_conf["cookieprefix"]."mybbuser","0",time() -3600,$this->mybb_conf["cookiepath"],$this->mybb_conf['cookiedomain']);
}
function register($sdata){
global $db, $config, $session, $functions;
$salt=$session->generate_Key(8);
if($sdata["pwd_sha2'"]!=''){
$saltetpass=md5(md5($salt).md5($session->generate_Key(15)));
}else{
$saltetpass=md5(md5($sdata["salt"]).$sdata["pwd_md5"]);
}
$db->query("INSERT INTO `" . $this->mybb_conf["prefix"] . "users` (`username`,`salt`,`password`,`loginkey`,`email`,`usergroup`,`birthday`,`regdate`,`regip`,`showsigs`,`showavatars`,`showquickreply`,`showredirect`,`style`,`receivepms`,`allownotices`,`pmnotice`,`pmnotify`,`birthdayprivacy`) VALUES ('".$rdata["username"]."','".$salt."','".$saltetpass."','".$session->generate_Key(50)."','".$sdata["email"]."','2','".date('j-n-Y',$sdata['birthday'])."','".time()."',".$db->escape_binary($functions->my_inet_pton($session->ip)).",'1','1','1','1','3','1','1','1','1','none')");
$lid=$db->last_id();
$db->query("UPDATE `" . $config["prefix"] . "users` SET `fuid`='".$lid."' WHERE `uid`='".$sdata["uid"]."'");
$db->query("INSERT INTO `" . $this->mybb_conf["prefix"] . "userfields` (`ufid`, `fid1`, `fid3`) VALUES ('".$lid."','".$sdata["from"]."','".$sdata["gender"]."')");
}
function add($rdata){
global $db, $config, $session, $functions;
$salt=$session->generate_Key(8);
if($rdata["pwd_sha2'"]!=''){
$saltetpass=md5(md5($salt).md5($session->generate_Key(15)));
}else{
$saltetpass=md5(md5($rdata["salt"]).$rdata["pwd_md5"]);
}
$db->query("INSERT INTO `" . $this->mybb_conf["prefix"] . "users` (`username`,`salt`,`password`,`loginkey`,`email`,`usergroup`,`regdate`,`regip`,`showsigs`,`showavatars`,`showquickreply`,`showredirect`,`style`,`receivepms`,`allownotices`,`pmnotice`,`pmnotify`) VALUES ('".$rdata["name"]."','".$salt."','".$saltetpass."','".$session->generate_Key(50)."','".$rdata["email"]."','2','".time()."',".$db->escape_binary($functions->my_inet_pton($session->ip)).",'1','1','1','1','3','1','1','1','1')");
$lid=$db->last_id();
$db->query("UPDATE `" . $config["prefix"] . "users` SET `fuid`='".$lid."' WHERE `uid`='".$rdata["uid"]."'");
}
function lostpwd($sdata){
global $db, $config, $session;
$salt=$session->generate_Key(8);
$saltetpass=md5(md5($salt).$sdata["pwd_md5"]);
$result = $db->query("SELECT `fuid` FROM `" . $config["prefix"] . "users` WHERE `uid`='".$sdata["uid"]."' LIMIT 1");
$u=$db->fetch_array($result);
$db->query("UPDATE `" . $this->mybb_conf["prefix"] . "users` SET `salt`='".$salt."',`password`='".$saltetpass."',`loginkey`='".$session->generate_Key(50)."' WHERE `uid`='".$u["fuid"]."'");
}
function usercp($rdata){
global $db, $config, $session;
$result = $db->query("SELECT `fuid` FROM `" . $config["prefix"] . "users` WHERE `uid`='".$rdata["uid"]."' LIMIT 1");
$u=$db->fetch_array($result);
if($rdata['pwd_sha2']!=NULL){
$salt=$session->generate_Key(8);
$saltetpass=md5(md5($salt).$rdata["pwd_md5"]);
$pwd=",`password`='".$saltetpass."',`salt`='".$salt."',`loginkey`='".$session->generate_Key(50)."'";
}
$db->query("UPDATE `" . $this->mybb_conf["prefix"] . "users` SET `email`='".$rdata["email"]."'".$pwd." WHERE `uid`='".$u["fuid"]."'");
}
function update($rdata){
global $db, $config, $session;
$result = $db->query("SELECT `fuid` FROM `" . $config["prefix"] . "users` WHERE `uid`='".$rdata["uid"]."' LIMIT 1");
$u=$db->fetch_array($result);
if($rdata['password']!=""){
$salt=$session->generate_Key(8);
$saltetpass=md5(md5($salt).md5($rdata["password"]));
$pwd=",`password`='".$saltetpass."',`salt`='".$salt."',`loginkey`='".$session->generate_Key(50)."'";
}
$db->query("UPDATE `" . $this->mybb_conf["prefix"] . "users` SET `username`='".$rdata["name"]."',`email`='".$rdata["email"]."'".$pwd." WHERE `uid`='".$u["fuid"]."'");
if($rdata['active']==2){
$db->query("DELETE FROM `" . $this->mybb_conf["prefix"] . "banned` WHERE `uid`='".$u["fuid"]."'");
$db->query("UPDATE `" . $this->mybb_conf["prefix"] . "users` SET `usergroup`='7' WHERE `uid`='".$u["fuid"]."'");
$db->query("INSERT INTO `" . $this->mybb_conf["prefix"] . "banned` (`uid`,`gid`,`oldgroup`,`oldadditionalgroups`,`olddisplaygroup`,`admin`,`dateline`,`bantime`,`lifted`,`reason`) VALUES ('".$u["fuid"]."','7','2','','0','".$rdata['user_fid']."','".time()."','---','0','')");
}
}
function delete($data){
global $db, $config, $cache, $log;
$fdata=$db->query("SELECT * FROM `" . $this->mybb_conf["prefix"] . "users` WHERE `uid`='".$data['fuid']."'");
$forumdata = $db->fetch_array($fdata);
$this->delete_query("userfields", "ufid='".$data['fuid']."'");
$this->delete_query("privatemessages", "uid='".$data['fuid']."'");
$this->delete_query("events", "uid='".$data['fuid']."'");
$this->delete_query("forumsubscriptions", "uid='".$data['fuid']."'");
$this->delete_query("threadsubscriptions", "uid='".$data['fuid']."'");
$this->delete_query("sessions", "uid='".$data['fuid']."'");
$this->delete_query("banned", "uid='".$data['fuid']."'");
$this->delete_query("threadratings", "uid='".$data['fuid']."'");
$this->delete_query("users", "uid='".$data['fuid']."'");
$this->delete_query("joinrequests", "uid='".$data['fuid']."'");
$this->delete_query("warnings", "uid='".$data['fuid']."'");
$this->delete_query("reputation", "uid='".$data['fuid']."' OR adduid='".$data['fuid']."'");
$this->delete_query("awaitingactivation", "uid='".$data['fuid']."'");
$this->delete_query("posts", "uid = '".$data['fuid']."' AND visible = '-2'");
$this->delete_query("threads", "uid = '".$data['fuid']."' AND visible = '-2'");
if($forumdata['avatartype'] == "upload")
{
// Removes the ./ at the beginning the timestamp on the end...
@unlink("/var/www/forum.archer.agency/web/htdocs/uploads/avatars/".substr($user['avatar'], 2, -20));
}
$db->query("UPDATE `" . $this->mybb_conf["prefix"] . "posts` SET `uid`=0 WHERE `uid`='".$data['fuid']."'");
$db->query("UPDATE `" . $this->mybb_conf["prefix"] . "forums` SET `lastposteruid`=0 WHERE `lastposteruid`='".$data['fuid']."'");
$db->query("UPDATE `" . $this->mybb_conf["prefix"] . "threads` SET `lastposteruid`=0 WHERE `lastposteruid`='".$data['fuid']."'");
}
function fetchboardconfig(){
global $db, $config, $cache, $log;
$mybb=$cache->read('mybbconfig');
try{
$result = $db->query("SELECT `name`, `value` FROM " . $mybb['prefix'] . "settings");
if(!$result){
throw new Exception($db->error());
}
while ($row = $db->fetch_array($result)){
$boardconfig[$row['name']] = $row['value'];
}
$boardconfig['prefix']=$mybb['prefix'];
return $boardconfig;
}catch(Exception $e){
$log->write($e,2,__LINE__,__FILE__);
return NULL;
}
}
function delete_query($table, $where="", $limit="")
{
global $db, $config, $cache, $log;
$query = "";
if(!empty($where))
{
$query .= " WHERE $where";
}
if(!empty($limit))
{
$query .= " LIMIT $limit";
}
$db->query('DELETE FROM `' . $this->mybb_conf["prefix"] . $table .'`'. $query) or die($db->error());
}
}
?>