funchat/forumplugins/userupdate.php
2025-06-19 00:07:46 +02:00

104 lines
3.5 KiB
PHP

<?php
/**
* MyBB 1.4
* Copyright © 2008 MyBB Group, All Rights Reserved
*
* Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*
* $Id: hello.php 4304 2009-01-02 01:11:56Z chris $
*/
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("usercp_do_password_end", 'passupdate');
$plugins->add_hook("datahandler_user_update", 'userupdate');
//include "cache.class.php";
function userupdate_info()
{
/**
* Array of information about the plugin.
* name: The name of the plugin
* description: Description of what the plugin does
* website: The website the plugin is maintained at (Optional)
* author: The name of the author of the plugin
* authorsite: The URL to the website of the author (Optional)
* version: The version number of the plugin
* guid: Unique ID issued by the MyBB Mods site for version checking
* compatibility: A CSV list of MyBB versions supported. Ex, "121,123", "12*". Wildcards supported.
*/
return array(
"name" => "UserUpdate",
"description" => "Syncs the Site Database with the forum",
"website" => "https://funch.at",
"author" => "genuineparts",
"authorsite" => "http://funch.at",
"version" => "1.2",
"guid" => "",
"compatibility" => "*"
);
}
function passupdate($data)
{
global $db,$mybb;
$sql ="SELECT `uid` FROM `aa_users` WHERE `fuid` = '".$mybb->user['uid']."' LIMIT 1";
$query = $db->query($sql);
$chid = $db->fetch_array($query);
$salt = random_str(6);
$pass =hash('sha256',$db->escape_string($salt.$mybb->get_input('password')));
$loginkey = random_str(50);
$sql ="UPDATE `aa_users` SET `password`='".$pass."',`loginkey`='".$loginkey."',`salt`='".$salt."' WHERE `fuid` = '".$mybb->user['uid']."'";
$query = $db->query($sql);
$cookiedata = base64_encode($chid['uid'] .'_'. $loginkey);
us_setcookie('atchat_base', $cookiedata, time() + 60 * 60 * 24 * 365, '/','.funch.at',true);
}
function userupdate($data) {
global $db, $mybb;
//die('<pre>'.var_dump($data->data['profile_fields']['fid3']=='Männlich').'</pre>');
if($data->user_update_data['email']!=""){
$sql ="UPDATE `aa_users` SET `email`='".$data->user_update_data['email']."' WHERE `fuid` = '".$data->data['uid']."'";
$query = $db->query($sql);
}
if($data->user_update_data['username']!=""){
$sql ="UPDATE `aa_users` SET `username`='".$data->user_update_data['username']."' WHERE `fuid` = '".$data->data['uid']."'";
$query = $db->query($sql);
}
if($data->data['profile_fields']['fid3']!=""){
$gender = 'u';
if($data->data['profile_fields']['fid3']=="Mann") {
$gender = 'm';
} elseif ($data->data['profile_fields']['fid3']=="Frau") {
$gender = 'f';
}
$sql ="UPDATE `aa_users` SET `gender`='".$gender."' WHERE `fuid` = '".$data->data['uid']."'";
$query = $db->query($sql);
}
}
function us_setcookie($name,$data,$validto=0,$path=NULL,$domain=NULL,$httponly=false,$https=true)
{
if($domain!=''){
// Fix the domain to accept domains with and without 'www.'.
if (strtolower( substr($domain, 0, 4) ) == 'www.' ){
$domain = substr($domain, 4);
}else{
$domain = $domain;
}
// Add the dot prefix to ensure compatibility with subdomains
if ( substr($domain, 0, 1) != '.' ){
$domain = '.'.$domain;
}
}
if((isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS'])) || $https){
$https = true;
}
setcookie($name, $data, $validto, $path, $domain,$httponly,$https);
}
?>