public function goBack() { if ($this->request->hasHeader('HTTP_REFERER')) { $referer = $this->request->getHeader('HTTP_REFERER')[0]; return $this->response->withRedirect($referer, 301); } return $this->goHome(); }
public function __invoke(Request $req, Response $res) { $result = $this->authService->authenticate(); if (!$result->isValid()) { $this->flash->addMessage('danger', reset($result->getMessages())); return $res->withRedirect($this->loginUrl); } return $res->withRedirect($this->successUrl); }
public function edit(Request $request, Response $response, array $args) { $uid = $args['uid']; if (empty($uid)) { $this->flash->addMessage('flash', 'No record specified'); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts')); } $id = $this->authenticator->getIdentity(); $user = R::load('users', $id['id']); if ($uid != 'new') { $account = R::load('accounts', $uid); if ($account->id == 0) { $this->flash->addMessage('flash', 'No record found'); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts')); } // restrict access to own profile or Admin role if ($account->users->id != $id['id']) { if (strtolower($id['role']) != 'admin') { $this->flash->addMessage('flash', 'Access Denied'); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts')); } } } else { $account = R::dispense('accounts'); } if ($request->isPost()) { $data = $request->getParams(); $account->import($data, 'apikey,accountid,servertype'); $account->users = $user; $account->lasttid = 0; $oandaInfo = FALSE; // verify and get account balance try { $oandaInfo = new Broker_Oanda($account['servertype'], $account['apikey'], $account['accountid'], 0); } catch (\Exception $e) { $viewData['flash'] = 'Account Details Invalid'; } if ($oandaInfo != FALSE) { $aid = R::store($account); $oandaInfo->updateAccount(); $this->flash->addMessage('flash', "account updated"); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('editaccount', ['uid' => $aid])); } } $viewData['account'] = $account; $this->view->render($response, 'account.twig', $viewData); return $response; }
/** * Execute the middleware. * * @param ExtendedRequest $request * @param Response $response * @param callable $next * * @return Response */ public function __invoke(ExtendedRequest $request, Response $response, callable $next) { $router = $this->router; $route = $request->getCurrentRoute(); $locales = $this->locale; $locale = $locales->getDefault(); $lang = $route->getArgument($router->getLanguageIdentifier()); $lang = ltrim($lang, '/'); $redirect = false; if ($lang) { try { // Find language in list of available locales and set it as active $locale = $locales->findByLanguage($lang); $locales->setActive($locale); if ($router->isOmitDefaultLanguage() && $locale == $locales->getDefault()) { // Trigger redirect to correct path (as language set in path is default lang and we want to omit it) $redirect = true; } } catch (Exception $e) { // Trigger "notFound" as setActive() throws Exception if $locale is not valid / available $next = $this->notFoundHandler; } } elseif (!$router->isOmitDefaultLanguage()) { // Trigger redirect to correct path (as language is not set in path but we don't want to omit default lang) $redirect = true; } // Redirect to route with proper language identifier value set (or omitted) if ($redirect) { $path = $router->pathFor($route->getName(), $route->getArguments(), $request->getParams(), $locale->getLanguage()); $uri = $request->getUri()->withPath($path); return $response->withRedirect($uri); } return $next($request, $response); }
public function test(Request $request, Response $response, array $args) { $uid = $args['uid']; $myaccount = R::load('accounts', $uid); $accountId = $myaccount->accountid; $account = R::findOne('accounts', ' accountid = ?', [$accountId]); if (!empty($account)) { $apiKey = $account['apikey']; $type = $account['servertype']; $oandaInfo = new Broker_Oanda($type, $apiKey, $accountId); } else { $this->flash->addMessage('flash', "Oanda AccountId not found"); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('homepage')); } $side = 'buy'; $pair = 'EUR_USD'; $price = '1.1400'; $expiry = time() + 60; $stopLoss = '1.1300'; $takeProfit = NULL; $risk = 1; // $side='buy'; // $pair='GBP_CHF'; // $price='2.1443'; // $expiry = $oandaInfo->getExpiry(time()+60); // $stopLoss='2.1452'; // $takeProfit=NULL; // $risk=1; //$oandaInfo->placeLimitOrder($side,$pair,$price,$expiry,$stopLoss,$takeProfit,$risk); $oandaInfo->processTransactions(); }
public function deleteUser(Request $request, Response $response, array $args) { $name = $args['name']; if (empty($name)) { $this->flash->addMessage('flash', 'No user specified'); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('users')); } $user = R::findOne('users', ' email = ? ', [$name]); if (!empty($user)) { R::trash($user); $this->flash->addMessage('flash', "{$name} deleted"); } else { $this->flash->addMessage('flash', "{$name} User not found"); } return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('users')); }
public function __invoke(Request $req, Response $res) { if ($req->isPost()) { $adapter = $this->authService->getAdapter(); if ($adapter instanceof ValidatableAdapterInterface) { $adapter->setIdentity($req->getParam('identity')); $adapter->setCredential($req->getParam('credential')); } $result = $this->authService->authenticate($adapter); if (!$result->isValid()) { $this->flash->addMessage('danger', reset($result->getMessages())); return $res->withRedirect($req->getUri()); } return $res->withRedirect($this->successUrl); } return $this->view->render($res, 'user/login.twig', []); }
public function delete(Request $request, Response $response, array $args) { $skills = $this->data(MemberSkills::class); if ($skills->delete((int) $args['id'])) { $this->addFormAlert('success', 'Item Skill berhasil dihapus.'); } else { $this->addFormAlert('error', 'Sesuatu terjadi, skill gagal dihapus.'); } return $response->withRedirect($this->router->pathFor('membership-account')); }
public function __invoke(ServerRequestInterface $req, Response $res) { if ($this->authService->hasIdentity()) { $identity = $this->authService->getIdentity(); $events = $this->events; $this->authService->clearIdentity(); $events('trigger', 'logout', $identity, $this->redirectUrl); } return $res->withRedirect($this->redirectUrl); }
public function editUser(Request $request, Response $response, array $args) { $username = strtolower($args['username']); if (empty($username)) { $this->flash->addMessage('flash', 'No user specified'); return $response->withRedirect($this->router->pathFor('profile')); } $id = $this->authenticator->getIdentity(); // restrict access to own profile or Admin user if ($username != strtolower($id['name'])) { if (strtolower($id['name']) != 'admin') { $this->flash->addMessage('flash', 'Access Denied'); return $response->withRedirect($this->router->pathFor('profile')); } } if ($username != 'new') { $user = R::findOrCreate('users', ['name' => $username]); } else { $user = R::dispense('users'); } if ($request->isPost()) { $data = $request->getParams(); //$username = $request->getParam('username'); $user->import($data, 'fullname,shortdial,longdial,colour,mobile,home'); $user->name = $request->getParam('username'); $password = $request->getParam('password'); if (!empty($password)) { $pass = password_hash($password, PASSWORD_DEFAULT); $user->hash = $pass; } $id = R::store($user); $this->flash->addMessage('flash', "{$user->name} updated"); return $response->withRedirect($this->router->pathFor('edituser', ['username' => $username])); // $member = 'INSERT INTO `users` (`name`, `fullname`, `password`, `hash`, `colour`, `shortdial`, `longdial`, `mobile`, `home`, `ins_mf`, `ins_win`, `health_mf`, `health_win`, `life_mf`, `life_win`, `wealth_mf`, `wealth_win`, `uk_shift`, `atss`) VALUES ' // . "($username, $fullname, :pass, '', 'FAD2F5', $shortdial, $longdial, '', '', '1', '0', '0', '1', '0', '0', '0', '1', '0', '0'); // "; } $this->view->render($response, 'user.twig', $user->export()); return $response; }
/** * Example middleware invokable class * * @param Slim\Http\Request $request PSR7 request * @param Slim\Http\Response $response PSR7 response * @param callable $next Next middleware * * @return \Psr\Http\Message\ResponseInterface */ public function __invoke(Request $request, Response $response, $next) { $route = $request->getAttribute('route'); $session = $this->container->session; $user_id = $session->getVar('userid', 0); if (!$this->hasAccess($route, $user_id)) { $router = $this->container->router; //return $response->withStatus(403); return $response->withRedirect($router->pathFor('front-index')); } $response = $next($request, $response); return $response; }
public function editUser(Request $request, Response $response, array $args) { $username = $args['username']; if (empty($username)) { $this->flash->addMessage('flash', 'No user specified'); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('profile')); } $username = base64_decode($username); $id = $this->authenticator->getIdentity(); // restrict access to own profile or Admin role if ($username != strtolower($id['email'])) { if (strtolower($id['role']) != 'admin') { $this->flash->addMessage('flash', 'Access Denied'); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('profile')); } } $user = R::findOne('users', ' email = ? ', [$username]); if ($user == NULL) { $user = R::dispense('users'); } if ($request->isPost()) { $user->fullname = $request->getParam('userfullname'); $user->email = $request->getParam('username'); $password = $request->getParam('userpassword'); if (!empty($password)) { $pass = password_hash($password, PASSWORD_DEFAULT); $user->hash = $pass; } $id = R::store($user); $this->flash->addMessage('flash', "{$user->name} updated"); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('edituser', ['username' => base64_encode($username)])); } $expUser['user'] = $user->export(); $expUser['user']['hashemail'] = base64_encode($user['email']); $this->view->render($response, 'user.twig', $expUser); return $response; }
public function editUser(Request $request, Response $response, array $args) { $username = strtolower($args['username']); if (empty($username)) { $this->flash->addMessage('flash', 'No user specified'); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('profile')); } $id = $this->authenticator->getIdentity(); // restrict access to own profile or Admin user if ($username != strtolower($id['name'])) { if (strtolower($id['name']) != 'admin') { $this->flash->addMessage('flash', 'Access Denied'); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('profile')); } } if ($username != 'new') { $user = R::findOrCreate('users', ['name' => $username]); } else { $user = R::dispense('users'); } if ($request->isPost()) { $data = $request->getParams(); //$username = $request->getParam('username'); $user->import($data, 'fullname,colour,mobile,home'); $user->name = $request->getParam('username'); $password = $request->getParam('password'); if (!empty($password)) { $pass = password_hash($password, PASSWORD_DEFAULT); $user->hash = $pass; } $id = R::store($user); $this->flash->addMessage('flash', "{$user->name} updated"); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('edituser', ['username' => $username])); } $this->view->render($response, 'user.twig', $user->export()); return $response; }
/** * Execute the middleware. * * @param Request $request * @param Response $response * @param callable $next * * @return Response */ public function __invoke(Request $request, Response $response, callable $next) { $uri = $request->getUri(); $path = $uri->getPath(); // Add or remove slash as configured if ($path != '/') { $path = rtrim($path, '/'); if ($this->addSlash && !pathinfo($path, PATHINFO_EXTENSION)) { $path .= '/'; } } // Redirect if ($uri->getPath() !== $path) { return $response->withRedirect($uri->withPath($path), 301); } return $next($request, $response); }
/** * @param string $repo * @param string $file * @param int $width * @param bool $archived * @param \Slim\Http\Response $response * @return mixed */ function thumb($repo, $file, $width, $archived, $response, $format) { $md5 = md5($file); $file = $md5[0] . '/' . $md5[0] . $md5[1] . '/' . $file; $path = $repo . ($archived ? 'archive/' : '') . $file; if (is_readable($path)) { $path = realpath($path); $pathParts = pathinfo($path); if (strpos($pathParts['dirname'], $repo) === 0) { $cacheDir = $repo . 'thumb/' . ($archived ? 'archive/' : '') . $file; if (!is_dir($cacheDir)) { if (!mkdir($cacheDir, 0777, true)) { return $response->withStatus(403); } } if ($format != 'jpg') { $cacheFile = $cacheDir . '/' . $width . 'px-' . $pathParts['basename']; } else { $cacheFile = $cacheDir . '/' . $width . 'px-' . $pathParts['filename'] . '.jpg'; } if (!is_readable($cacheFile)) { $image = new ImageResize($path); if ($width > $image->getSourceWidth()) { return $response->withRedirect('/images/' . $file); } else { $image->resizeToWidth($width); if ($format != 'jpg') { $image->save($cacheFile); } else { $image->save($cacheFile, IMAGETYPE_JPEG); } } } $finfo = finfo_open(FILEINFO_MIME_TYPE); $type = finfo_file($finfo, $cacheFile); $stream = new \GuzzleHttp\Psr7\LazyOpenStream($cacheFile, 'r'); return $response->withHeader('Content-type', $type)->withBody($stream); } } return $response->withStatus(404); }
public function auth(Request $request, Response $response, callable $next) { $auth = $this->authenticator; $role = $this->getRole($auth->getIdentity()); $hasIdentity = $auth->hasIdentity(); $identity = $auth->getIdentity(); // $data = array( // 'hasIdentity' => $hasIdentity, // 'role' => $role, // 'identity' => $identity // ); if (!$hasIdentity) { //throw new HttpUnauthorizedException(); $_SESSION['urlRedirect'] = (string) $request->getUri(); //$app->flash('error', 'Login required'); return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('login')); } /* Everything ok, call next middleware. */ $response = $next($request, $response); return $response; }
/** * Invoke middleware. * * @param RequestInterface $req PSR7 request object * @param ResponseInterface $res PSR7 response object * @param callable $next Next middleware callable * * @return ResponseInterface PSR7 response object */ public function __invoke(Request $req, Response $res, callable $next) { if (!$req->getAttribute('route')) { return $res->withStatus(404); } $isAllowed = false; if ($this->acl->hasResource('route' . $req->getAttribute('route')->getPattern())) { $isAllowed = $isAllowed || $this->acl->isAllowed($this->currentUserRole, 'route' . $req->getAttribute('route')->getPattern(), strtolower($req->getMethod())); } if (is_string($req->getAttribute('route')->getCallable()) && $this->acl->hasResource('callable/' . $req->getAttribute('route')->getCallable())) { $isAllowed = $isAllowed || $this->acl->isAllowed($this->currentUserRole, 'callable/' . $req->getAttribute('route')->getCallable()); } if (!$isAllowed && $this->currentUserRole === $this->defaultRole) { return $res->withRedirect($this->loginUrl); } if (!$isAllowed) { $res = $res->withStatus(403, $this->currentUserRole . ' is not allowed access to this location.'); $res->getBody()->write('Forbidden'); return $res; } return $next($req, $res); }
/** * Redirect to specific route. * * @param Response $response * @param string $route The route to redirect to * @param array $data [optional] Route params * @param array $queryParams [optional] Query string params * @param string $suffix [optional] URL suffix like query string * * @return Response */ public function redirectToRoute(Response $response, $route, array $data = [], array $queryParams = [], $suffix = '') { $url = $this->router->pathFor($route, $data, $queryParams) . $suffix; return $response->withRedirect($url, 301); }
public function reactivate(Request $request, Response $response, array $args) { /** @var Users $users */ $users = $this->data(Users::class); $validator = $this->validator->rule('required', 'email'); $validator->addRule('assertNotEmailExists', function ($field, $value, array $params) use($users) { return !$users->assertEmailExists($value); }, 'Email tersebut tidak terdaftar!'); $validator->rule('assertNotEmailExists', 'email'); if ($validator->validate()) { // $this->addFormAlert('error', 'Bad Request'); } else { $this->addFormAlert('warning', 'Some of mandatory fields is empty!', $validator->errors()); return $response->withRedirect($this->router->pathFor('membership-login')); } return $response->withRedirect($this->router->pathFor('membership-account-reactivate')); }
protected function redirectToLoginPage(Request $request, Response $response) { $this->storeCurrentUrlInSession($request); return $response->withRedirect('/login', 303); }
public function teamAdd(Request $request, Response $response, $args) { $data = $request->getParsedBody(); /** @var EntityManager $em */ $em = $this->container->entityManager; $team = new Team(); $team->setName($data['name']); $team->setLeague($em->find('Fanta\\Entity\\League', $data['league_id'])); $team->setUser($em->find('Fanta\\Entity\\User', $data['user_id'])); $team->setName($data['name']); $em->persist($team); $em->flush(); return $response->withRedirect($this->container->router->pathFor('league-detail', array('league_id' => $data['league_id']))); }
public function reset(Request $request, Response $response, array $args) { /** @var Users $users */ $users = $this->data(Users::class); /** @var UsersResetPwd $usersResetPass */ $usersResetPass = $this->data(UsersResetPwd::class); if ($usersResetPass->verifyUserKey($args['uid'], $args['reset_key'])) { $success_msg = 'Password baru sementara anda sudah dikirim ke email. Segera check email anda. Terimakasih ^_^'; $success_msg_alt = 'Password baru sementara anda sudah dikirim ke email.<br><br><strong>Kemungkinan email akan sampai agak terlambat, karena email server kami sedang mengalami sedikit kendala teknis. Jika belum juga mendapatkan email, maka jangan ragu untuk laporkan kepada kami melalu email: report@phpindonesia.or.id</strong><br><br>Terimakasih ^_^'; // Fetch member basic info $member = $users->get(['username', 'email'], function ($query) use($args) { $query->where('user_id', '=', (int) $args['uid']); })->fetch(); $emailAddress = $member['email']; // Create temporary password $tmpPass = substr(str_shuffle(md5(microtime())), 0, 10); $users->update(['password' => $this->salt($tmpPass), 'modified_by' => 0], (int) $args['uid']); $usersResetPass->delete(['user_id' => (int) $args['uid'], 'reset_key' => $args['reset_key']]); // Then send new temporary password to email try { $emailSettings = $this->settings->get('email'); $message = \Swift_Message::newInstance('PHP Indonesia - Password baru sementara')->setFrom([$emailSettings['sender_email'] => $emailSettings['sender_name']])->setTo([$emailAddress => $member['username']])->setBody(file_get_contents(APP_DIR . 'views' . _DS_ . 'email' . _DS_ . 'password-change-ok-confirmation.txt')); $this->mailer->registerPlugin(new \Swift_Plugins_DecoratorPlugin([$emailAddress => ['{temp_pwd}' => $tmpPass]])); $this->mailer->send($message); $this->addFormAlert('success', $success_msg); } catch (\Swift_TransportException $e) { $this->addFormAlert('success', $success_msg_alt); } } else { $this->addFormAlert('error', 'Bad Request'); } return $response->withRedirect($this->router->pathFor('membership-login')); }
/** * @param \Slim\Http\Request $request * @param \Slim\Http\Response $response * @return \Slim\Http\Response */ private function responseWithDenial(Request $request, Response $response) { $message = 'Permission denied, authorization required.'; // Response with json if XHR request if ($request->isXhr()) { return $response->withJson(['message' => $message], 401); } // Response with redirect if otherwise $this->flash->addMessage('error', $message); return $response->withRedirect($this->router->pathFor('membership-account')); }
/** * @covers Slim\Http\Response::withRedirect */ public function testWithRedirect() { $response = new Response(200); $clone = $response->withRedirect('/foo', 301); $this->assertSame(200, $response->getStatusCode()); $this->assertFalse($response->hasHeader('Location')); $this->assertSame(301, $clone->getStatusCode()); $this->assertTrue($clone->hasHeader('Location')); $this->assertEquals('/foo', $clone->getHeaderLine('Location')); }
public function deleted(Request $request, Response $response, array $args) { $this->addFormAlert('warning', 'This feature is disabled'); return $response->withRedirect($this->router->pathFor('membership-profile', ['username' => $this->session->get('username')])); }
public function change(Request $request, Response $response, array $args) { $this->logger->info("Oncall Change page action dispatched"); $rota = strtolower($args['rota']); $display = 6; $name = $request->getParam('name', ''); $prev = $request->getParam('prev', 0); $day = $request->getParam('day'); $month = $request->getParam('month'); $monthObj = \DateTime::createFromFormat('!m', $month); $monthName = $monthObj->format('F'); $year = $request->getParam('year'); $title = "Please select who is oncall for - {$day} {$monthName} {$year}"; if (!empty($name)) { $rotaUser = R::findOne('users', ' name = :username ', ['username' => $name]); if (empty($rotaUser)) { $this->flash->addMessage('flash', "{$name} not found"); return $response->withRedirect($this->router->pathFor('oncall', ['rota' => $rota])); } $oldDay = (int) $day; $oldMonth = (int) $month; $oldYear = (int) $year; $whatDay = 8 - date('w', mktime(0, 0, 0, $oldMonth, $oldDay, $oldYear)); if ($whatDay == 8 || $request->getParam('allweek') == null) { $whatDay = 1; } for ($x = 0; $x < $whatDay; $x++) { $day = date('j', mktime(0, 0, 0, $oldMonth, $oldDay + $x, $oldYear)); $month = date('n', mktime(0, 0, 0, $oldMonth, $oldDay + $x, $oldYear)); $year = date('Y', mktime(0, 0, 0, $oldMonth, $oldDay + $x, $oldYear)); $rotaDay = R::findOrCreate($rota, ['day' => $day, 'month' => $month, 'year' => $year]); $rotaDay->name = $rotaUser; $id = $this->authenticator->getIdentity(); $whoUser = R::load('users', $id['id']); $rotaDay->who = $whoUser; $rotaDay->stamp = date("Y-m-d H:i:s"); R::store($rotaDay); } $this->flash->addMessage('flash', "Rota updated"); return $response->withRedirect($this->router->pathFor('oncall', ['rota' => $rota])); } $rotaBean = R::findOne('rotas', ' name = :name ', [':name' => $rota]); if (empty($rotaBean)) { $this->flash->addMessage('flash', "sorry {$rota} not found"); return $response->withRedirect($this->router->pathFor('homepage')); } $userlist = []; $users = $rotaBean->sharedUsersList; foreach ($users as $user) { $userlist[] = ['colour' => $user['colour'], 'linkday' => '<a href="?name=' . $user['name'] . "&day={$day}&month={$month}&year={$year}\">" . $user['fullname'] . "</a>", 'linkweek' => '<a href="?name=' . $user['name'] . "&day={$day}&month={$month}&year={$year}&allweek=Y\">" . $user['fullname'] . "</a>"]; } $this->view->render($response, 'change.twig', ['rota' => $rota, 'title' => $title, 'userlist' => $userlist]); return $response; }
/** * Redirect to video file. * * @param Request $request PSR-7 request * @param Response $response PSR-7 response * * @return Response HTTP response */ public function redirect(Request $request, Response $response) { $params = $request->getQueryParams(); if (isset($params['url'])) { try { $url = $this->download->getURL($params['url'], $params['format']); return $response->withRedirect($url); } catch (\Exception $e) { $response->getBody()->write($e->getMessage()); return $response->withHeader('Content-Type', 'text/plain'); } } }
/** * @param \Slim\Http\Response $response * @return \Slim\Http\Response */ public function convert($response) { switch ($this->height) { case 0: $h = '_nopic'; break; case 1080: $h = ''; break; default: $h = '_' . $this->height; } if (!$this->colorImgs) { $h = '_nocolors' . $h; } $part_filename = '/' . $this->nameurl . '/' . $this->escapedFileName() . $h . $this->getExt(); $bin = false; if (!$this->nocache) { $cache_filename = $this->config['folder'] . $part_filename; $ftp_filename = '/srv/ftp/ruranobe.ru/d/' . $this->getExt() . $part_filename; $ftp_dirname = dirname($ftp_filename); $json = $this->apiCall('disk/resources', ['fields' => 'modified', 'path' => $cache_filename]); if (!isset($json->modified) || $this->touched > strtotime($json->modified)) { $bin = $this->convertImpl($this->text_to_convert); if (!is_dir($ftp_dirname)) { mkdir($ftp_dirname, 0755, true); } file_put_contents($ftp_filename, $bin); $json = $this->apiCall('disk/resources', ['path' => dirname($cache_filename)], [CURLOPT_PUT => true]); if (isset($json->error) && $json->error == 'DiskPathDoesntExistsError') { $this->apiCall('disk/resources', ['path' => dirname(dirname($cache_filename))], [CURLOPT_PUT => true]); $this->apiCall('disk/resources', ['path' => dirname($cache_filename)], [CURLOPT_PUT => true]); } $json = $this->apiCall('disk/resources/upload', ['overwrite' => 'true', 'path' => $cache_filename]); if (!empty($json->href)) { $tmpfile = tempnam(sys_get_temp_dir(), 'cvcache'); file_put_contents($tmpfile, $bin); $fp = fopen($tmpfile, 'r'); $curl_upl = curl_init(); curl_setopt($curl_upl, CURLOPT_HTTPHEADER, ['Authorization: OAuth ' . $this->config['key']]); curl_setopt($curl_upl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_upl, CURLOPT_URL, $json->href); curl_setopt($curl_upl, CURLOPT_INFILE, $fp); curl_setopt($curl_upl, CURLOPT_INFILESIZE, filesize($tmpfile)); curl_setopt($curl_upl, CURLOPT_PUT, true); curl_setopt($curl_upl, CURLOPT_UPLOAD, true); curl_exec($curl_upl); curl_close($curl_upl); fclose($fp); unlink($tmpfile); } else { trigger_error("Cannot upload convertor cache of file '{$part_filename}' - no upload link", E_USER_WARNING); } } $json = $this->apiCall('disk/public/resources/download', ['path' => $part_filename, 'public_key' => $this->config['public_key']]); if (isset($json->href)) { return $response->withRedirect($json->href); } } if (!$bin) { $bin = $this->convertImpl($this->text_to_convert); error_log('converted ' . $part_filename . '. peak memory usage: ' . memory_get_peak_usage()); } return $this->makeDownload($bin, $response); }
public function editForm($idTicket) { $response = Item::with(['asignado', 'tipoItem', 'transiciones' => function ($query) { $query->orderBy('TransicionItem.fechahora', 'Desc'); }, 'transiciones.usuario', 'comentarios' => function ($query) { $query->orderBy('Comentario.fechahora', 'Desc'); }, 'comentarios.usuario'])->find($idTicket); if (true === is_null($response)) { $response = new Response(); return $response->withRedirect($this->container->path('my_tickets', true)); } $Item = new Item(); $estadoActual = $Item->estadoActual($idTicket)->get(); $workflow = $Item->workFlow($idTicket)->get(); $states = []; $states['workflow'] = []; $idEstado = 0; foreach ($estadoActual as $key => $estado) { $states['workflow'][] = ['id' => $estado->idEstado, 'nombre' => $estado->nombreEstado, 'tipo' => $estado->tipoEstado]; $idEstado = $estado->idEstado; } foreach ($workflow as $key => $estado) { $states['workflow'][] = ['id' => $estado->idEstado, 'nombre' => $estado->nombreEstado]; } $tipoItems = TipoItem::tipoItemsProyecto($response->proyecto->idProyecto)->get(); $usuarios_atencion = $this->usersByState($idEstado); $data_relations = []; $data_relations['tipo_items'] = []; foreach ($tipoItems as $tipoitem) { $data = []; $data['id'] = $tipoitem->idTipoItem; $data['descripcion'] = $tipoitem->descripcion; $data['estados'] = []; foreach ($tipoitem->estados()->get() as $key => $estado) { $data['estados'][$key] = ['id' => $estado->idEstado, 'nombre' => $estado->nombreEstado]; } array_push($data_relations['tipo_items'], $data); } return $this->render('tickets/editar.html.twig', ['ticket' => $response, 'relaciones' => '', 'workflow' => $states['workflow'], 'equipo' => $usuarios_atencion]); }
public function deleteRota(Request $request, Response $response, array $args) { $name = $args['name']; if (empty($name)) { $this->flash->addMessage('flash', 'No rota specified'); return $response->withRedirect($this->router->pathFor('rotas')); } $rota = R::findOne('rotas', ' name = ? ', [$name]); if (!empty($rota)) { R::trash($rota); R::wipe($name); $this->flash->addMessage('flash', "{$name} deleted"); } else { $this->flash->addMessage('flash', "{$name} Rota not found"); } return $response->withRedirect($this->router->pathFor('rotas')); }