Example #1
0
function bh_auth_set_password($username, $password)
{
    # Update the db row
    $result = update_bhdb("users", array("password" => md5($password)), array("username" => $username));
    # The _bhdb functions return false for success.
    return true;
}
Example #2
0
function bh_setview($username, $filepath, $view)
{
    # Get our prefs for this dir, if we have any
    $filepathrows = select_bhdb("usersviews", array("username" => $username, "filepath" => $filepath), 1);
    if (empty($filepathrows)) {
        insert_bhdb("usersviews", array("username" => $username, "filepath" => $filepath, "view" => $view), "");
    } else {
        update_bhdb("usersviews", array("view" => $view), array("username" => $username, "filepath" => $filepath));
    }
}
Example #3
0
function bh_changeconfig($variable, $value)
{
    global $bhconfig;
    # See if it's already in the db.
    $rows = select_bhdb("config", array("variable" => $variable), 1);
    # If it is...
    if (!empty($rows)) {
        # Update it
        update_bhdb("config", array("value" => addslashes($value)), array("variable" => $variable));
    } else {
        # Add it
        insert_bhdb("config", array("variable" => $variable, "value" => addslashes($value)));
    }
}
Example #4
0
    } elseif ($uploadrows[0]['status'] = "finished") {
        # Echo window closing script
        $str = "<html>\n<head>\n</head>\n<body>\n<script>self.close();</script>\n</body>\n</html>";
        echo $str;
        # Remove entry in DB
        delete_bhdb("uploads", array("sessionid" => session_id()));
    } else {
        bh_log("Fatal error in upload notification system", "BH_ERROR");
    }
} elseif (count($fupload) > 0) {
    # Notify the popup to close
    $uploadrows = select_bhdb("uploads", array("sessionid" => session_id()), 1);
    if (empty($uploadrows)) {
        insert_bhdb("uploads", array("sessionid" => session_id(), "status" => "finished"));
    } else {
        update_bhdb("uploads", array("status" => "finished"), array("sessionid" => session_id()));
    }
    # Calculate used bandwidth
    foreach ($fupload as $fileinfo) {
        bh_bandwidth($bhsession['username'], "up", $fileinfo['size']);
    }
    # Check they can write to the destination directory
    if (bh_checkrights($infolder, $bhsession['username']) >= 2) {
        foreach ($fupload as $fileinfo) {
            # If it's a valid upload...
            if (empty($fileinfo['name']) !== TRUE) {
                # Check the file actually exists.
                if (file_exists($fileinfo['tempname'])) {
                    # Create thing of banned exts
                    $bannedexts = array("exexexexex" => 1);
                    $invalid = False;
Example #5
0
        $quota = "";
    } else {
        if (!is_numeric($user['quota']) || $user['quota'] < 0) {
            bh_add_error($bhlang['error:quota_not_a_number']);
            require "error.inc.php";
            return;
        } else {
            $quota = round($user['quota'] * 1024 * 1024);
        }
    }
    # Update type & disabled
    update_bhdb("users", array("type" => $user['type'], "disabled" => $user['disabled'], "quota" => $quota), array("username" => $editusername));
    # If new password, update it
    if (!empty($user['pass1'])) {
        if ($user['pass1'] == $user['pass2']) {
            update_bhdb("users", array("password" => md5($user['pass1'])), array("username" => $editusername));
            bh_log($bhlang['notice:user_updated'], "BH_NOTICE");
            require "modules/users.inc.php";
        } else {
            bh_log($bhlang['error:passwords_dont_match'], "BH_ERROR");
        }
    } else {
        bh_log($bhlang['notice:user_updated'], "BH_NOTICE");
        require "modules/users.inc.php";
    }
} else {
    $userobj = new bhuser($editusername);
    $userobj->userinfo['type'] = $userobj->type;
    $userobj->userinfo['disabled'] = $userobj->disabled;
    $userobj->userinfo['quota'] = round($userobj->quota / (1024 * 1024), 2);
    $layout = new bhadminlayout("edituser");
Example #6
0
 function set_grouprights($group, $status, $recursion = 1)
 {
     if ($this->is_dir() && $recursion == 1) {
         $this->loadfile();
         foreach ($this->filecontents as $file2set) {
             $file2setobj = new bhfile($file2set['filepath']);
             $file2setobj->set_grouprights($group, $status);
         }
     }
     if ($status >= 0) {
         $grouprows = select_bhdb("aclgroups", array("group" => $group, "filepath" => $this->filepath), "");
         if (!empty($grouprows)) {
             update_bhdb("aclgroups", array("status" => $status), array("group" => $group, "filepath" => $this->filepath));
         } else {
             insert_bhdb("aclgroups", array("group" => $group, "filepath" => $this->filepath, "status" => $status));
         }
     } else {
         delete_bhdb("aclgroups", array("group" => $group, "filepath" => $this->filepath));
     }
 }
Example #7
0
            bh_log($bhlang['error:passwords_dont_match'], "BH_ERROR");
        }
    } else {
        # Tell them what they did wrong
        bh_log($bhlang['error:old_password_invalid'], "BH_ERROR");
    }
}
# See if there's an incoming profile change request
if (!empty($_POST['changeprofile'])) {
    # Go through the options and add/update them
    foreach ($_POST['changeprofile'] as $option => $value) {
        $optionrows = select_bhdb("userinfo", array("username" => $bhsession['username'], "itemname" => $option), "");
        if (empty($optionrows)) {
            insert_bhdb("userinfo", array("username" => $bhsession['username'], "itemname" => $option, "itemcontent" => $value));
        } else {
            update_bhdb("userinfo", array("itemcontent" => $value), array("username" => $bhsession['username'], "itemname" => $option));
        }
    }
    # Say it's updated
    bh_log($bhlang['notice:profile_saved'], "BH_NOTICE");
}
# Get user profile info
$profilerows = select_bhdb("userinfo", array("username" => $bhsession['username']), "");
$profile = array();
foreach ($profilerows as $profilerow) {
    $profile[$profilerow['itemname']] = $profilerow['itemcontent'];
}
# Open layout object
$layoutobj = new bhlayout("options");
# Send the content to the layout
$layoutobj->title = $bhlang['title:options'];
Example #8
0
             $layoutobj->title = $bhlang['title:signup'];
             $layoutobj->content1 = "<br><br>" . $bhlang['error:validation_link_wrong'];
             $layoutobj->display();
         } else {
             # check if it's already at stage 1.
             $regs1rows = select_bhdb("registrations", array("regid" => $_GET['confirmregid'], "username" => $_GET['username'], "status" => "0"), "");
             if (empty($regs1rows)) {
                 # Open layout object
                 $layoutobj = new bhlayout("generic");
                 # Send the file listing to the layout, along with directory name
                 $layoutobj->title = $bhlang['title:signup'];
                 $layoutobj->content1 = "<br><br>" . $bhlang['notice:validation_already_done_pending_approval'];
                 $layoutobj->display();
             } else {
                 # Up the reg row status
                 update_bhdb("registrations", array("status" => "1"), array("regid" => $_GET['confirmregid'], "username" => $_GET['username']));
                 # All done. Say so.
                 bh_log($bhlang['log:user_validated_'] . $username, "BH_SIGNUP_VALIDATED");
                 bh_log($bhlang['log:user_signup_m_pending_'] . $username, "BH_SIGNUP_M_PENDING");
                 # Open layout object
                 $layoutobj = new bhlayout("generic");
                 # Send the file listing to the layout, along with directory name
                 $layoutobj->title = $bhlang['title:signup'];
                 $layoutobj->content1 = "<br><br>" . $bhlang['notice:moderation_now_pending'];
                 $layoutobj->display();
             }
         }
     }
 } else {
     # Open layout object
     $layoutobj = new bhlayout("signup");
Example #9
0
function bh_session_destroy()
{
    global $dbconfig, $bhconfig;
    # Mark the session as not logged in
    $oldprefix = $dbconfig['prefix'];
    $olddb = $dbconfig['db'];
    $dbconfig['prefix'] = $bhconfig['phpbb_prefix'];
    $dbconfig['db'] = $bhconfig['phpbb_db'];
    update_bhdb("sessions", array("session_logged_in" => "0", "session_user_id" => "-1"), array("session_id" => $sessid));
    $dbconfig['prefix'] = $oldprefix;
    $dbconfig['db'] = $olddb;
    return array("username" => "");
}
Example #10
0
 function set_grouprights($group, $status)
 {
     $grouprows = select_bhdb("aclgroups", array("group" => $group, "filepath" => $this->filepath), "");
     if (!empty($grouprows)) {
         update_bhdb("aclgroups", array("status" => $status), array("group" => $group, "filepath" => $this->filepath));
     } else {
         insert_bhdb("aclgroups", array("group" => $group, "filepath" => $this->filepath, "status" => $status));
     }
 }