<?php require_once 'includes/common.php'; try { if (count($_FILES) > 0) { logger('Uploading file to hackyrepositorymanager: ' . current($_FILES)['name']); $file = current($_FILES); checkUploadedFileProblems($file); $origin = $file['name']; try { $repo = getRepositoryByPackageFilename($origin); } catch (Exception $e) { $repo = getRepositoryByName('default'); } $destin = $repo->getBaseDir() . $file['name']; logger("Writing {$origin} to {$destin}"); $res = move_uploaded_file($file['tmp_name'], $destin); if (!$res) { throw new Exception("Could not move uploaded file"); } writePackageMetadata($file['name'], $repo); @unlink($repo->getBaseDir() . '/latest'); symlink($file['name'], $repo->getBaseDir() . '/latest'); doPostActions($repo->getBaseDir(), $file['name']); logger('Package ' . $file['name'] . ' uploaded to repo: ' . $repo->getName()); } else { logger("No files provided to upload"); } } catch (Exception $e) { logger($e); }
function getRepositoryByPackageFilename($filename) { foreach (getRoutes() as $route) { $source = null; switch ($route->type) { case 'jenkins': if (isset($_SERVER['HTTP_JOB_NAME'])) { $source = $_SERVER['HTTP_JOB_NAME']; } break; case 'filename': $source = $filename; break; default: continue; } if (ruleEval($source, $route)) { echo "Matched: {$route->line}\n"; return getRepositoryByName($route->destination); } else { echo 'Rule does not match: ' . $route->line . "\n"; } } throw new Exception('Could not determine which repo to use.'); }
<?php require_once 'includes/widgets/header.php'; $name = san()->filterString('name'); $repo = getRepositoryByName($name); $repo->delete(); require_once 'includes/widgets/footer.php';