Esempio n. 1
0
    }
}
?>

<div class="maincontainer">
  <?php 
if (isset($_POST['type'])) {
    $type = $_POST['type'];
    if ($type == 1) {
        $valid = AddonFileHandler::validateAddon($filename);
    } else {
        if ($type == 2) {
            $valid = AddonFileHandler::validatePrint($filename);
        } else {
            if ($type == 3) {
                $valid = AddonFileHandler::validateColorset($filename);
            }
        }
    }
    if (!$valid) {
        echo "Your add-on is missing required files!";
    }
} else {
    header('Location: index.php');
}
?>
  Tags<br />
  Screenshots<br />
  Authors<br />
  Version
</div>
Esempio n. 2
0
 public static function uploadNewAddon($user, $name, $type, $file, $filename, $description)
 {
     $database = new DatabaseManager();
     AddonManager::verifyTable($database);
     $rsc = $database->query("SELECT * FROM `addon_addons` WHERE `name` = '" . $database->sanitize($name) . "' LIMIT 1");
     //I think we should enforce a unique file name, but not a unique addon name
     if ($rsc->num_rows > 0) {
         $response = ["message" => "An add-on by this name already exists!"];
         $rsc->close();
         return $response;
     }
     $rsc->close();
     $rsc = $database->query("SELECT * FROM `addon_addons` WHERE `filename` = '" . $database->sanitize($filename) . "'");
     if ($rsc->num_rows > 0) {
         $response = ["message" => "An add-on with this filename already exists!"];
         $rsc->close();
         return $response;
     }
     $rsc->close();
     $bid = 1;
     // TODO Specify branch in upload
     //generate blank version data
     $versionInfo = AddonFileHandler::getVersionInfo($file);
     var_dump($versionInfo);
     if ($versionInfo !== false) {
         // information to use for upstream repos
         $version = new stdClass();
         $version->stable = new stdClass();
         $version->stable->version = $versionInfo->version;
         $version->stable->restart = "0.0.0";
         $url = parse_url($versionInfo->repo->url);
         if (!isset($url['host'])) {
             $url['host'] = $versionInfo->repo->url;
         }
         if ($url['host'] == "blocklandglass.com" || $url['host'] == "api.blocklandglass.com") {
             // nothing?
         } else {
             $upstream = new stdClass();
             $upstream->url = $versionInfo->repo->url;
             if (isset($versionInfo->repo->mod)) {
                 $upstream->mod = $versionInfo->repo->mod;
             }
             $upstream->branch = array();
             $upstream->branch[$bid] = $versionInfo->channel;
             $version->upstream = $upstream;
         }
     } else {
         $version = new stdClass();
         $version->stable = new stdClass();
         $version->stable->version = "0.0.0";
         $version->stable->restart = "0.0.0";
         $repo = new stdClass();
     }
     $authorInfo = new stdClass();
     $authorInfo->blid = $user->getBlid();
     $authorInfo->main = true;
     $authorInfo->role = "Manager";
     $authorArray = [$authorInfo];
     // NOTE boards will be decided by reviewers now, they just seem to confuse and anger people
     // I think making that change at this point will cause more problems than it solves.
     // It is better to just have reviewers move boards
     $res = $database->query("INSERT INTO `addon_addons` (`id`, `board`, `blid`, `name`, `filename`, `description`, `versionInfo`, `authorInfo`, `reviewInfo`, `deleted`, `approved`, `uploadDate`) VALUES " . "(NULL," . "NULL," . "'" . $database->sanitize($user->getBlid()) . "'," . "'" . $database->sanitize($name) . "'," . "'" . $database->sanitize($filename) . "'," . "'" . $database->sanitize($description) . "'," . "'" . $database->sanitize(json_encode($version)) . "'," . "'" . $database->sanitize(json_encode($authorArray)) . "'," . "'{}'," . "'0'," . "'0'," . "CURRENT_TIMESTAMP);");
     if (!$res) {
         throw new Exception("Database error: " . $database->error());
     }
     $id = $database->fetchMysqli()->insert_id;
     AddonFileHandler::injectGlassFile($id, $file);
     //AddonFileHandler::injectVersionInfo($id, $bid, $file); // TODO need to specify branch in upload
     require_once realpath(dirname(__FILE__) . '/AWSFileManager.php');
     //AWSFileManager::uploadNewAddon($id, $bid, $filename, $file);
     require_once realpath(dirname(__FILE__) . '/StatManager.php');
     StatManager::addStatsToAddon($id);
     $response = ["redirect" => "/addons/upload/success.php?id=" . $id];
     return $response;
 }
Esempio n. 3
0
    }
    //to do: aws stuff instead of this
    move_uploaded_file($tempPath, $tempLocation);
    chmod($tempLocation, 0777);
    $type = $_POST['type'];
    //these should probably return an array with something like
    //	'ok' => true/false
    //	'message' => descriptive message
    if ($type == 1) {
        $valid = AddonFileHandler::validateAddon($tempLocation);
    } else {
        if ($type == 2) {
            $valid = AddonFileHandler::validatePrint($tempLocation);
        } else {
            if ($type == 3) {
                $valid = AddonFileHandler::validateColorset($tempLocation);
            } else {
                $valid = false;
            }
        }
    }
    if (!$valid) {
        $response = ["message" => "Your add-on is missing required files"];
        return $response;
    } else {
        //repeated but slightly different path from above?
        $tempLocation = realpath(dirname(__DIR__) . "/../addons/upload/files/" . $filename);
        $response = AddonManager::uploadNewAddon($user, $uploadAddonName, $type, $tempLocation, $uploadFileName, $uploadDescription);
        return $response;
    }
}
 public static function approveUpdate($update)
 {
     $database = new DatabaseManager();
     AddonManager::verifyTable($database);
     $id = $update->getId();
     if ($update->status !== null) {
         throw new Exception("Attempted to approve already approved update");
     }
     $update->status = true;
     $database->query("UPDATE `addon_updates` SET `approved` = b'1' WHERE `id` = '" . $database->sanitize($id) . "'");
     $database->query("UPDATE `addon_addons` SET `version` = '" . $database->sanitize($update->version) . "' WHERE `id` = '" . $database->sanitize($update->aid) . "'");
     AddonFileHandler::injectGlassFile($update->aid, $update->getFile());
     AddonFileHandler::injectVersionInfo($update->aid, 1, $update->getFile());
     AWSFileManager::uploadNewAddon($update->aid, 1, $update->getAddon()->getFilename(), $update->getFile());
     $params = new stdClass();
     $addon = new stdClass();
     $addon->type = "addon";
     $addon->id = $update->getAddon()->getId();
     $params->vars[] = $addon;
     NotificationManager::createNotification($manager, 'Your update to $1 was approved', $params);
     @unlink($update->getFile());
 }
    mkdir(dirname(dirname(__DIR__)) . "/addons/upload/files/");
}
//to do: aws stuff instead of this
move_uploaded_file($tempPath, $tempLocation);
chmod($tempLocation, 0777);
/*
$type = $_GET['t'];

//these should probably return an array with something like
//	'ok' => true/false
//	'message' => descriptive message
if($type == "addon" || $type == "client") {
  $valid = AddonFileHandler::validateAddon($tempLocation);
} else if($type == "other") {
  $valid = AddonFileHandler::validateAddon($tempLocation) || AddonFileHandler::validateColorset($tempLocation);
} else {
  $valid = false;
}
*/
$valid = AddonFileHandler::validateAddon($tempLocation) || AddonFileHandler::validateColorset($tempLocation) || AddonFileHandler::validatePrint($tempLocation);
if (!$valid) {
    $response = ["message" => "Your add-on is missing required files"];
    return $response;
} else {
    //repeated but slightly different path from above?
    $tempLocation = realpath(dirname(__DIR__) . "/../addons/upload/files/" . $filename);
    $response = AddonManager::uploadNewAddon($user, $uploadAddonName, $type, $tempLocation, $uploadFileName, $uploadDescription, $type);
    return $response;
}
//}
return $response;