Example #1
1
 public function Delete($files, \Slim\Slim &$app, $page)
 {
     $obj = new Files();
     $obj->parseFile($files);
     $user_id = $obj->user_id;
     //$cookieDB = $obj->cookie;
     $cookie = $app->getCookie('username');
     $db = $app->db;
     $logged = new Logged();
     $id = $logged->getLogged($db, $cookie);
     //checking of the user is registered in Users table as the user or anonymous which added this file and getting his id
     if ($id == $user_id) {
         $foo = new Foo();
         $foo->token = $page;
         $mapper = new FooMapper($db);
         $files = $mapper->delete($foo);
         $path = $obj->path;
         $filename = "uploads/" . $path;
         //deleting file from the folder
         unlink($filename);
         $app->redirect('/TwigBlog/');
     } else {
         $app->error();
     }
 }
Example #2
0
File: Logout.php Project: etu/0bRSS
 public function get()
 {
     $cookieName = session_name();
     $sessionParams = session_get_cookie_params();
     // Unset cookie in browser
     setcookie($cookieName, false, 1, $sessionParams['path'], $sessionParams['domain'], $sessionParams['secure']);
     $this->slim->redirect($this->slim->request->getRootUri() . '/login');
 }
Example #3
0
File: Feeds.php Project: etu/0bRSS
 public function post()
 {
     // Read JSON from Body-input
     $requestData = json_decode($this->slim->request->getBody());
     // Create feed
     $feedId = $this->feedsDao->create($_SESSION['user']['id'], ['name' => $requestData->name, 'website_uri' => $requestData->website_uri, 'feed_uri' => $requestData->feed_uri, 'update_interval' => $requestData->update_interval]);
     // Redirect to the new API-Resource to tell the client where it is
     $this->slim->redirect($this->slim->request->getRootUri() . '/api/feeds/' . $feedId);
 }
Example #4
0
 public function redirect($url, $status = 302)
 {
     if (filter_var($url, FILTER_VALIDATE_URL) === false) {
         parent::redirect((Config::get('url_rewrite', true) ? '' : '/index.php') . $url, $status);
     } else {
         parent::redirect($url, $status);
     }
 }
Example #5
0
 /**
  * @param $location
  * @param $status
  */
 public function redirect($location, $status = 302)
 {
     try {
         $this->app->redirect($location, $status);
     } catch (\Slim\Exception\Stop $e) {
         // do nothing
     }
 }
Example #6
0
 function routes(\Slim\Slim $app)
 {
     $base = $this->getBasePath();
     $app->get($base . '/', function () use($app) {
         $app->redirect($app->Doc->getBasePath() . '/api-doc/');
     });
     $app->get($base . '/api-doc/json', function () use($app) {
         $app->Doc->json();
     });
     $app->get($base . '/api-doc/', function () use($app) {
         $app->Doc->ui();
     });
     $app->get($base . '/api-doc/json/:name', function ($name) use($app) {
         $app->Doc->api($name);
     });
 }
 public function checkRequirements()
 {
     $paths = Utils::getPaths(SW_PATH . "/engine/Shopware/Components/Check/Data/Path.xml");
     clearstatcache();
     $systemCheckPathResults = Utils::checkPaths($paths, SW_PATH);
     foreach ($systemCheckPathResults as $value) {
         if (!$value['result']) {
             $fileName = SW_PATH . '/' . $value['name'];
             @mkdir($fileName, 0777, true);
             @chmod($fileName, 0777);
         }
     }
     clearstatcache();
     $systemCheckPathResults = Utils::checkPaths($paths, SW_PATH);
     $hasErrors = false;
     foreach ($systemCheckPathResults as $value) {
         if (!$value['result']) {
             $hasErrors = true;
         }
     }
     $directoriesToDelete = ['engine/Library/Mpdf/tmp' => false, 'engine/Library/Mpdf/ttfontdata' => false];
     CommonUtils::clearOpcodeCache();
     $results = [];
     foreach ($directoriesToDelete as $directory => $deleteDirecory) {
         $result = true;
         $filePath = SW_PATH . '/' . $directory;
         Utils::deleteDir($filePath, $deleteDirecory);
         if ($deleteDirecory && is_dir($filePath)) {
             $result = false;
             $hasErrors = true;
         }
         if ($deleteDirecory) {
             $results[$directory] = $result;
         }
     }
     if (!$hasErrors && $this->app->request()->get("force") !== "1") {
         // No errors, skip page except if force parameter is set
         $this->app->redirect($this->app->urlFor("dbmigration"));
     }
     $isSkippableCheck = $this->app->config('skippable.check');
     if ($isSkippableCheck && $this->app->request()->get("force") !== "1") {
         // No errors, skip page except if force parameter is set
         $this->app->redirect($this->app->urlFor("dbmigration"));
     }
     $this->app->render('checks.php', ['systemCheckResultsWritePermissions' => $systemCheckPathResults, 'filesToDelete' => $results, 'error' => $hasErrors]);
 }
Example #8
0
 /**
  * Redirect controller
  *
  * @param string $path
  * @return void
  */
 protected function redirect($path)
 {
     $path = str_replace('//', '/', $this->app->baseURL . $path);
     $this->app->redirect($path);
 }
Example #9
0
 public function action_logout(\Slim\Slim $app)
 {
     $app->user->logout();
     $app->redirect("/");
 }
Example #10
0
        if (isset($matches[1])) {
            $format = $matches[1];
        }
        $picture = new Picture($conf, DEFAULT_PICTURE, $app_base_url);
        $display = $picture->getDisplay($format);
        $response = $app->response();
        foreach ($display['headers'] as $key => $header) {
            $response[$key] = $header;
        }
        $response->body($display['content']);
    } else {
        $app->render('50x.html.twig', array('exception' => $e));
    }
});
//main route
$app->get('/', function () use($app, $app_base_url) {
    $app->redirect($app_base_url . '/viewer/' . DEFAULT_PICTURE);
});
//include routes files
require_once 'routes/images.routes.php';
require_once 'routes/series.routes.php';
require_once 'routes/ajax.routes.php';
if (APP_DEBUG === true) {
    include_once 'routes/debug.routes.php';
}
if (!defined('APP_TESTS')) {
    $app->run();
    if (isset($profiler)) {
        $profiler->stop();
    }
}
Example #11
0
 public function redirect($name, $params = array(), $routeName = true)
 {
     $url = $routeName ? $this->urlFor($name, $params) : $name;
     parent::redirect($url);
 }
$app->group('/', function () use($app) {
    $app->get('/', function () use($app) {
    });
});
$app->group('/login', function () use($app) {
    $app->get('/', function () use($app) {
        $app->render('login.php');
    });
    $app->post('/', function () use($app) {
        $data = $app->request()->post();
        $login = new LoginController();
        $result = $login->login($data);
        if ($result) {
            $app->flash('msgInfo', 'Bienvenido ' . $_SESSION['user']);
            if ($_SESSION['tipo'] == 1) {
                $app->redirect(URL . 'pacientes');
            }
            if ($_SESSION['tipo'] == 2) {
                $app->redirect(URL . 'turnos');
            }
            if ($_SESSION['tipo'] == 3) {
                $app->redirect(URL . 'guardias');
            }
            if ($_SESSION['tipo'] == 4) {
                $app->redirect(URL . 'turnos');
            }
        } else {
            $app->flash('msgError', 'Datos incorrectos.');
            $app->redirect(URL . 'login');
        }
    });
Example #13
0
File: App.php Project: bistro/swell
 /**
  * {@inheritDoc}
  */
 public function redirect($url, $status = 302)
 {
     parent::redirect($this->getWebPath() . $url, $status);
 }
$app->get('/download_report', function () use($app, $config) {
    $fileName = $app->request()->params('filename');
    echo "<pre>";
    echo file_get_contents($config['log_files_path'] . $fileName);
});
$app->get('/process/', function () use($app, $config) {
    $fileName = $app->request()->params('filename');
    $locker = new ProcessLocker($config['lock_file']);
    if (!$locker->isLocked()) {
        $splitter = new CsvSplitter(new CsvFile($fileName), $config['output_csv_path']);
        $splitter->split($config['split_size']);
        $command = $config['nohup_path'] . ' ' . $config['php_path'] . ' ' . __DIR__ . '/src/shell/csv_importer.php ' . $config['output_csv_path'] . '  > /dev/null 2>&1 &';
        $process = new Process($command, $config['proc_working_path']);
        $process->run();
    }
    $app->redirect('/csv_batch_process/index.php');
});
use Helpers\Magento\MageWrapper;
use Repositories\Magento\CatalogRepository;
use Repositories\Magento\EavCatalogProductRepository;
use Processors\Magento\ProductImporter;
$app->get('/test/', function () use($app, $config) {
    ini_set('max_execution_time', -1);
    Mage::app('admin', 'store', array('global_ban_use_cache' => true))->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
    $mageWrapper = new MageWrapper(Mage);
    $eavRepository = new EavCatalogProductRepository($mageWrapper);
    $catalogRepository = new CatalogRepository($mageWrapper, $eavRepository);
    $magentoProcessor = new ProductImporter($catalogRepository);
    $magentoProcessor->process(new CsvFile('sample.csv'), 'sample.csv');
});
$app->get('/test_splitter/', function () use($app, $config) {
Example #15
0
File: App.php Project: bd808/quips
 /**
  * Configure routes to be handled by application.
  *
  * @param \Slim\Slim $slim Application
  */
 protected function configureRoutes(\Slim\Slim $slim)
 {
     $middleware = array('must-revalidate' => function () use($slim) {
         $slim->response->headers->set('Cache-Control', 'private, must-revalidate, max-age=0');
         $slim->response->headers->set('Expires', 'Thu, 01 Jan 1970 00:00:00 GMT');
     }, 'inject-user' => function () use($slim) {
         $user = $slim->authManager->getUserData();
         $slim->view->set('user', $user);
     }, 'require-user' => function () use($slim) {
         if ($slim->authManager->isAnonymous()) {
             if ($slim->request->isGet()) {
                 $uri = $slim->request->getUrl() . $slim->request->getPath();
                 $qs = Form::qsMerge();
                 if ($qs) {
                     $uri = "{$uri}?{$qs}";
                 }
                 $_SESSION[AuthManager::NEXTPAGE_SESSION_KEY] = $uri;
             }
             // FIXME: use i18n
             $slim->flash('error', 'Login required');
             $slim->flashKeep();
             $slim->redirect($slim->urlFor('login'));
         }
     });
     $slim->group('/', $middleware['inject-user'], function () use($slim, $middleware) {
         App::redirect($slim, '', 'random', 'home');
         App::redirect($slim, 'index', 'random');
         $slim->get('random', function () use($slim) {
             $page = new Pages\Random($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page();
         })->name('random');
         $slim->get('random.json', function () use($slim) {
             $slim->response->headers->set('Content-Type', 'application/json');
             $page = new Pages\Random($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page->setTemplate('random.json');
             $page();
         })->name('random.json');
         $slim->get('search', function () use($slim) {
             $page = new Pages\Search($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page();
         })->name('search');
         $slim->get('top', function () use($slim) {
             $page = new Pages\Top($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page();
         })->name('top');
         App::template($slim, 'login');
         $slim->get('logout', $middleware['must-revalidate'], function () use($slim) {
             $slim->authManager->logout();
             $slim->redirect($slim->urlFor('home'));
         })->name('logout');
         App::template($slim, 'about');
         App::template($slim, 'help');
     });
     // end group '/'
     $slim->group('/quip/', $middleware['inject-user'], function () use($slim, $middleware) {
         $slim->get(':id', function ($id) use($slim) {
             $page = new Pages\Quip($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page($id);
         })->name('quip');
         $slim->get(':id/edit', $middleware['require-user'], function ($id) use($slim) {
             $page = new Pages\Edit($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page($id);
         })->name('edit');
         $slim->post(':id/post', $middleware['require-user'], function ($id) use($slim) {
             $page = new Pages\Edit($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page($id);
         })->name('edit_post');
         $slim->post(':id/delete', $middleware['require-user'], function ($id) use($slim) {
             $page = new Pages\Delete($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page($id);
         })->name('delete_post');
         $slim->post(':id/vote', $middleware['require-user'], function ($id) use($slim) {
             $page = new Pages\Vote($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setQuips($slim->quips);
             $page($id);
         })->name('vote_post');
     });
     $slim->group('/oauth/', function () use($slim) {
         $slim->get('', function () use($slim) {
             $page = new Pages\OAuth($slim);
             $page->setOAuth($slim->oauthClient);
             $page('init');
         })->name('oauth_init');
         $slim->get('callback', function () use($slim) {
             $page = new Pages\OAuth($slim);
             $page->setI18nContext($slim->i18nContext);
             $page->setOAuth($slim->oauthClient);
             $page->setUserManager($slim->userManager);
             $page('callback');
         })->name('oauth_callback');
     });
     $slim->notFound(function () use($slim) {
         $slim->render('404.html');
     });
 }
Example #16
0
 public function redirect($url, $status = 302)
 {
     $url = BASE_URL . $url;
     \Slim\Slim::redirect($url, $status);
 }
Example #17
0
File: Slim.php Project: lalop/aphet
 protected function redirectTo($path)
 {
     $this->app->redirect($this->urlFor($path));
 }
Example #18
0
 protected function redirect($url, $status = 302)
 {
     $this->app->redirect($url, $status);
 }
Example #19
0
});
$app->get('/history', function () use($app) {
    $page = intval($app->request->get('page'));
    if (empty($page)) {
        $page = 1;
    }
    $offset = ($page - 1) * 5;
    $archives = $app->opentok->listArchives($offset, 5);
    $toArray = function ($archive) {
        return $archive->toArray();
    };
    $app->render('history.html', array('archives' => array_map($toArray, $archives->getItems()), 'showPrevious' => $page > 1 ? '/history?page=' . ($page - 1) : null, 'showNext' => $archives->totalCount() > $offset + 5 ? '/history?page=' . ($page + 1) : null));
});
$app->get('/download/:archiveId', function ($archiveId) use($app) {
    $archive = $app->opentok->getArchive($archiveId);
    $app->redirect($archive->url);
});
$app->get('/start', function () use($app, $sessionId) {
    $archive = $app->opentok->startArchive($sessionId, "PHP Archiving Sample App");
    $app->response->headers->set('Content-Type', 'application/json');
    echo $archive->toJson();
});
$app->get('/stop/:archiveId', function ($archiveId) use($app) {
    $archive = $app->opentok->stopArchive($archiveId);
    $app->response->headers->set('Content-Type', 'application/json');
    echo $archive->toJson();
});
$app->get('/delete/:archiveId', function ($archiveId) use($app) {
    $app->opentok->deleteArchive($archiveId);
    $app->redirect('/history');
});
Example #20
0
 public static function redirect(Slim $app, Session $session, $forward = false)
 {
     // redirect them to intended url if required
     if ($forward) {
         if ($session->get('urlRedirect')) {
             $tmp = $session->get('urlRedirect');
             $session->remove('urlRedirect');
             $app->redirect($app->request->getRootUri() . $tmp);
         }
     } else {
         //log them in and send to home page
         $app->redirect($app->request->getRootUri() . '/');
     }
 }
Example #21
0
 // setup variables from the incoming post
 $album = $app->request->post('album');
 $email = $app->request->post('email');
 $code = strtoupper($app->request->post('code'));
 $subscribe = $app->request->post('mailing_list');
 $address = $app->request->post('address');
 // Set current entries to cookies
 $app->setCookie('code', $code);
 $app->setCookie('email', $email);
 $app->setCookie('album', $album);
 $app->setCookie('subscribe', $subscribe);
 // Make sure the Honey Pot field is empty.
 if (!empty($address)) {
     $app->flash('error', 'Your form submission has an error.');
     // Push them back to the main screen with generic error message
     $app->redirect($app->urlFor('home'));
 } elseif (!empty($code) && !empty($email)) {
     // Clean up the form submissions
     $cleanCode = filter_var($code, FILTER_SANITIZE_STRING);
     $cleanEmail = filter_var($email, FILTER_SANITIZE_EMAIL);
     $cleanAlbum = filter_var($album, FILTER_SANITIZE_STRING);
     // validate the email format
     $validEmail = filter_var($cleanEmail, FILTER_VALIDATE_EMAIL);
     // Validate the code entered
     $validCode = $dl->validate_code($album, $code);
     // Check if the code and email entered are valid
     if ($validEmail && $validCode === 200) {
         // Subscribe the user if they kept the subscribe option checked
         if ($subscribe) {
             $addUser = $mail->newsletterSignup($cleanEmail);
             print_r($addUser);
Example #22
0
<?php

require '../vendor/autoload.php';
$config = (require_once __DIR__ . '/../config.php');
use FA\DI\Container;
use Slim\Slim;
// Prepare app
$app = new Slim($config['slim']);
$container = new Container($app, $config);
$app->hook('slim.before.router', function () use($app, $container) {
    $users = count($container['userDao']->findAll());
    $pathInfo = $app->request->getPathInfo();
    if ($users < 1 && $pathInfo != '/setup') {
        return $app->redirect('/setup');
    }
});
$app->get('/setup', function () use($app, $container) {
    if (count($container['userDao']->findAll()) > 0) {
        $app->halt(403);
    }
    $app->render('setup.html');
});
$app->post('/setup', function () use($app, $container) {
    if (count($container['userDao']->findAll()) > 0) {
        $app->halt(403, 'NO MOAR USERS ALLOWED');
    }
    $params = $app->request()->post();
    $email = filter_var($params['email'], FILTER_SANITIZE_EMAIL);
    $email = filter_var($email, FILTER_VALIDATE_EMAIL);
    if ($email) {
        try {
Example #23
0
        $authData = $app->auth->getIdentity();
        $authData['department_name'] = getNameForID($app->db, $authData['department']);
        $app->view()->appendData(array('userInfo' => $authData));
    }
    $app->view()->appendData(array('site_root' => $app->environment['SCRIPT_NAME'] . '/'));
});
$app->get('/', function () use($app) {
    $app->render('html/index.html');
})->name('index');
$app->get('/login', function () use($app) {
    $app->render('html/login.html');
})->name('login');
$app->post('/login', function () use($app) {
    $result = $app->authenticator->authenticate($app->request->post('username'), $app->request->post('password'));
    if ($result->isValid()) {
        $app->redirect($app->urlFor('profile'));
    } else {
        $app->flash('error', 'Invalid username or password provided');
        $app->redirect($app->urlFor('login'));
    }
});
$app->get('/logout', function () use($app) {
    $app->authenticator->logout();
    $app->redirect($app->urlFor('index'));
});
$app->get('/pwreset/:guid', function ($guid) use($app) {
    if (checkGUID($app->db, $guid)) {
        $app->render('html/pwreset.html', array('guid' => $guid));
    } else {
        $app->notFound();
    }
Example #24
0
    $app->log->info("Echolink CRON System - Update was performed from a remote server echolink.org");
    if ($echolinksys->responseStat != System::RESPONSE_OK) {
        $app->log->info("Echolink CRON System - Server problem ! (CODE: " . $echolinksys->responseStat . ")");
        $echolinksys->addHistoryLog("Server response problem! (CODE: " . $echolinksys->responseStat . ")");
    } else {
        $body = "Byl změněn stav převaděče.\r\n" . "Call: ";
        foreach ($echolinksys->messageEmail as $email) {
            //set template for email!
            $body = "Byl změněn stav převaděče.\r\n" . "Call: " . $email["callname"] . "\r\n" . "Nyní stav: " . ($email["newStatus"] == 1 ? "true" : "false") . "\r\n" . "Datum poslední změny: " . $email["oldCheckDate"] . "\r\n" . "Datum nynější změny: " . $email["checkDate"] . "\r\n";
            $echolinksys->mail($email["email"], "Echolink", $body, $from_name = "EcholinkSyS");
            $echolinksys->addHistoryLog("E-mail send to " . $email["callname"]);
            $app->log->info("Echolink CRON System - Email send to " . $email["callname"]);
        }
    }
    $url = $app->urlFor('list', array());
    $app->redirect($url);
})->name('check');
// updating data
$app->get('/cron', function () use($app) {
    $app->log->info("Echolink CRON System - '/cron' route");
    $echolinksys = new System("mysql:host=" . host . ";dbname=" . database, username, password);
    $echolinksys->dataFromTheServer();
    $app->log->info("Echolink CRON System - CRON -> Update was performed from a remote server echolink.org");
    if ($echolinksys->responseStat != System::RESPONSE_OK) {
        $app->log->info("Echolink CRON System - Server problem ! (CODE: " . $echolinksys->responseStat . ")");
        $echolinksys->addHistoryLog("Server response problem! (CODE: " . $echolinksys->responseStat . ")");
    } else {
        $body = "Byl změněn stav převaděče.\r\n" . "Call: ";
        foreach ($echolinksys->messageEmail as $email) {
            //set template for email!
            $body = "Byl změněn stav převaděče.\r\n" . "Call: " . $email["callname"] . "\r\n" . "Nyní stav: " . ($email["newStatus"] == 1 ? "true" : "false") . "\r\n" . "Datum poslední změny: " . $email["oldCheckDate"] . "\r\n" . "Datum nynější změny: " . $email["checkDate"] . "\r\n";
Example #25
0
        $app->response->finalize();
    }
    $app->logger->alert('UNHANDLED EXCEPTION', array('exception' => $e));
    if (isset($_SESSION['username']) && !empty($_SESSION['username'])) {
        return $app->render('errors/500-authed.mustache');
    }
    $app->render('errors/500-guest.mustache');
});
$app->view(new Mustache());
$app->view->parserOptions = $config['mustache'];
$app->view->appendData(array('copyrightYear' => date('Y')));
$app->add(new Navigation());
$app->add(new SessionCookie(array('expires' => '12 hours')));
$isLoggedIn = function () use($app) {
    if (empty($_SESSION['username'])) {
        $app->redirect($app->urlFor('home'));
    }
};
// home
$app->get('/', function () use($app) {
    $isAuthenticated = empty($_SESSION['username']) ? false : true;
    $app->render('home/index.mustache', array('isAuthenticated' => $isAuthenticated));
})->name('home');
$app->get('/login', function () use($app) {
    $app->redirect($app->urlFor('home'));
});
// login
$app->post('/login', function () use($app) {
    $params = $app->request()->post();
    // make sure the user name was passed.
    $username = trim($params['username']);