public function release_action($release_id) { $release = new MarketRelease($release_id); if ($release->isNew()) { throw new Exception("Unknown release."); } if (!$release['repository_download_url']) { //might happen more often than we think, so we better be polite and die. echo "Nothing to do."; die; } if ($release->getSecurityHash() === Request::get("s")) { if ($release['repository_secret'] && !$this->verify_secret($release['repository_secret'])) { $this->render_text("Incorrect payload."); return; } else { $release->installFile(); $this->render_text("OK"); } } else { $this->render_text("Insecure request."); } }
public function save_action() { if (!Request::isPost()) { throw new Exception("Method not allowed. Try a POST request."); } $this->marketplugin = new MarketPlugin(Request::option("id") ?: null); if (!$this->marketplugin->isNew() && !$this->marketplugin->isWritable()) { throw new AccessDeniedException("Kein Zugriff"); } if (Request::submitted("data")) { $data = Request::getArray("data"); if (!isset($data["publiclyvisible"])) { $data['publiclyvisible'] = 0; } if (!isset($data["donationsaccepted"])) { $data['donationsaccepted'] = 0; } $this->marketplugin->setData($data); if ($this->marketplugin->isNew()) { $this->marketplugin['user_id'] = $GLOBALS['user']->id; } } $this->marketplugin->store(); $this->marketplugin->setTags(array_map("trim", explode(",", Request::get("tags")))); if (Request::submitted("image_order")) { $order = array_flip(Request::getArray("image_order")); foreach ($this->marketplugin->images as $image) { $image['position'] = $order[$image->getId()] + 1; $image->store(); } } if (Request::submitted("delete_image")) { foreach (Request::getArray("delete_image") as $image_id) { MarketImage::find($image_id)->delete(); } } if (Request::submitted("edit_images")) { $files = $_FILES['new_images']; $position = count($this->marketplugin->images); foreach ($files['name'] as $index => $name) { if ($files['size'][$index]) { $position++; $file = new MarketImage(); $file['plugin_id'] = $this->marketplugin->getId(); $file['filename'] = $name; $file['mimetype'] = mime_content_type($files['tmp_name'][$index]); $file['position'] = $position; $file->installFromPath($files['tmp_name'][$index]); $file->store(); } } } if (Request::submitted("release")) { $release_data = Request::getArray("release"); if ($release_data['type'] !== "zipfile" || $_FILES['release_file']['tmp_name']) { $release = new MarketRelease(); if (!isset($release_data['repository_overwrites_descriptionfrom'])) { $release_data['repository_overwrites_descriptionfrom'] = 0; } $release->setData($release_data); $release['plugin_id'] = $this->marketplugin->getId(); $release['user_id'] = $GLOBALS['user']->id; $release->installFile(); $release->store(); } } PageLayout::postMessage(MessageBox::success(_("Plugin wurde gespeichert."))); $this->redirect('presenting/details/' . $this->marketplugin->getId()); }