BlocklandGlass / GlassWebsite

The old Glass website.
https://blocklandglass.com
4 stars 5 forks source link

Uploading an add-on with the filename of a deleted add-on will say it already exists #47

Open Draaked opened 7 years ago

31547 commented 6 years ago

does the upload script check a database that stores deleted add-ons as well? if deleted add-ons are removed from wherever the cross-check database is, this will be fixed

31547 commented 6 years ago

the problem is that when you try to delete an add-on whatever script actually handles the deletion doesn't remove it from the database. an entry still exists in the database in the addon_addons table. if the deletion script changed the filename or removed the entry from the addon_addons table, that would fix the problem.

see the evidence below to understand what im talking about.

https://github.com/BlocklandGlass/GlassWebsite/blob/master/private/class/AddonManager.php

lines 77 to 94 of the AddonManager class called elsewhere to validate/upload addons

public static function uploadNewAddon($user, $boardId, $name, $file, $filename, $description, $summary, $version) {

    //================================
    // Validation
    //================================

    $rsc = $database->query("SELECT * FROM `addon_addons` WHERE `name` = '" . $database->sanitize($name) . "' AND `approved` != '-1' LIMIT 1");

    if($rsc->num_rows > 0) {

        $response = [
            "message" => "An add-on by this name already exists!"
        ];

        $rsc->close();

        return $response;
    }

$rsc->close();