public function get($name)
 {
     $value = $this->request->get($name);
     if ($value === null) {
         $value = $this->request->post($name);
     }
     if ($value === null) {
         $value = @$this->defaultValues[$name];
     }
     return $value;
 }
 /**
  * @throws \RuntimeException
  */
 public function unpack()
 {
     // Manual updates do not contain files to overwrite
     if (UPDATE_IS_MANUAL) {
         Utils::clearOpcodeCache();
         $this->toJson(200, $this->resultMapper->toExtJs(new FinishResult(0, 0)));
         return;
     }
     $offset = $this->request->get('offset');
     $total = $this->request->get('total');
     /** @var FilesystemFactory $factory */
     $factory = $this->container->get('filesystem.factory');
     $localFilesystem = $factory->createLocalFilesystem();
     $remoteFilesystem = $factory->createRemoteFilesystem();
     if ($offset == 0) {
         $this->validateFilesytems($localFilesystem, $remoteFilesystem);
     }
     /** @var PathBuilder $pathBuilder */
     $pathBuilder = $this->container->get('path.builder');
     $debug = false;
     $step = new UnpackStep($localFilesystem, $remoteFilesystem, $pathBuilder, $debug);
     $result = $step->run($offset, $total);
     if ($result instanceof ValidResult) {
         Utils::clearOpcodeCache();
     }
     $this->toJson(200, $this->resultMapper->toExtJs($result));
 }
 /**
  * 
  *
  * @Route /tutorial
  * 
  * 
  * @param \Slim\Http\Request $request
  * @param \Slim\Http\Response $response
  * @param \Slim\Route $route
  */
 public function turorialAction($request, $response, $route)
 {
     $interactive = $this->get('InteractiveManager');
     $user = '******';
     if ($this->app->getSecurity()->isAuthenticated()) {
         $array = $this->app->getSecurity()->getUser();
         $user = $array['username'];
     }
     $store = json_encode(array('reject' => false, 'tutoriales' => array('interactive' => 'This is interactive')));
     if ($this->app->getCookie('Interactive_' . $user, true) == NULL) {
         $this->app->setCookie('Interactive_' . $user, $store, strtotime('+30 day'));
     } else {
         $store = json_decode($this->app->getCookie('Interactive_' . $user, true));
         $store->tutoriales->{$request->get('name')} = 0;
         $this->app->setCookie('Interactive_' . $user, json_encode($store), strtotime('+30 day'));
     }
     $interactive->setCurrentData($store);
     return $this->JSON($interactive->getTutorial($request->get('name')));
 }
 protected function __construct(\Slim\Http\Request $request)
 {
     $key = $request->headers('apikey');
     if ($key == '') {
         $key = $request->post('apikey');
     }
     if ($key == '') {
         $key = $request->get('apikey');
     }
     if ($key == '') {
         return;
     }
     $this->apiKey = $key;
     $this->role = $this->getRoleFromKey($this->apiKey);
 }
 /**
  * 
  *
  * @Route /bundle/installer/module
  * 
  * 
  * @param \Slim\Http\Request $request
  * @param \Slim\Http\Response $response
  * @param \Slim\Route $route
  */
 public function bundleInstallerModuleAction($request)
 {
     $msg = "";
     if ($request->get('name') and $request->get('type') == 'local') {
         $dir = \Raptor2\InstallerBundle\Importer\BundleImporter::prepareCache();
         $meta = \Raptor2\InstallerBundle\Importer\BundleImporter::getMetainformation($request->get('name'));
         if ($meta !== false) {
             \Raptor\Util\Files::copy(__DIR__ . '/../BundleStorage/files/' . $meta['file'], $dir);
             $msg = \Raptor2\InstallerBundle\Importer\BundleImporter::proccesBundle($dir . '/' . $meta['file']);
         }
     } elseif ($request->get('name') and $request->get('type') == 'remote' and $request->get('url')) {
         $file = \Raptor2\InstallerBundle\Importer\BundleImporter::downloadRemoteFile($request->get('url'));
         $msg = \Raptor2\InstallerBundle\Importer\BundleImporter::proccesBundle($file);
     }
     $local = \Raptor2\InstallerBundle\Importer\BundleImporter::getMetainformation();
     $conf = $this->getApp()->getConfigurationLoader()->getConfOption();
     if (isset($conf['raptor']['repository'])) {
         $remote = \Raptor2\InstallerBundle\Importer\BundleImporter::getRemoteMetainformation($conf['raptor']['repository']);
         $local = array_merge($local, $remote);
     }
     return $this->render('@InstallerBundle/installer/index.html.twig', array('modules' => $local, 'message' => $msg));
 }
Exemple #6
0
 /**
  * Creates a page object out of a request object
  * @param \Slim\Http\Request $request
  * @return Page
  */
 public static function createFromRequest(\Slim\Http\Request $request)
 {
     return new Page($request->get('offset'), $request->get('limit', 10));
 }
Exemple #7
0
 public function extractToken(Request $request)
 {
     $tokenHeader = $request->headers('Authorization', false);
     $rawTokenHeader = $request->rawHeaders('Authorization', false);
     if ($tokenHeader && preg_match('/Bearer\\s*([^\\s]+)/', $tokenHeader, $matches)) {
         $tokenHeader = $matches[1];
     } elseif ($rawTokenHeader && preg_match('/Bearer\\s*([^\\s]+)/', $rawTokenHeader, $matches)) {
         $tokenHeader = $matches[1];
     } else {
         $tokenHeader = false;
     }
     $tokenRequest = $request->post('access_token', false);
     $tokenQuery = $request->get('access_token', false);
     // At least one (and only one) of client credentials method required.
     if (!$tokenHeader && !$tokenRequest && !$tokenQuery) {
         throw new Exception('The request is missing a required parameter.', Resource::STATUS_BAD_REQUEST);
     } elseif ($tokenHeader && $tokenRequest || $tokenRequest && $tokenQuery || $tokenQuery && $tokenHeader) {
         throw new Exception('The request includes multiple credentials.', Resource::STATUS_BAD_REQUEST);
     }
     $accessToken = $tokenHeader ?: $tokenRequest ?: $tokenQuery;
     try {
         $tokenDocument = $this->fetchToken($accessToken);
     } catch (\Exception $e) {
         throw new Exception('Access token invalid.');
     }
     return $tokenDocument;
 }
 public function getSlimView(\Slim\Http\Request $request)
 {
     if ($request->isAjax() || $request->isXhr() || $request->get('format', '') == 'json' || $request->post('format', '') == 'json') {
         return $this->slimViewFactory->getJsonSlimView();
     }
     return $this->slimViewFactory->getHtmlSlimView();
 }