Example #1
0
    $controller = new FrontController($app);
    $controller->callAction('login');
})->name('login_view');
$app->post('/login', function () use($app) {
    $controller = new FrontController($app);
    $controller->callAction('loginA');
})->name('login_post');
$app->get('/logout', function () use($app) {
    session_start();
    $s = new Session();
    $session = $s->getSession();
    if ($session != null) {
        $_SESSION['user'] = array();
        session_destroy();
    }
    $app->redirect($app->urlFor('index'));
})->name('logout');
$app->get('/ayuda', function () use($app) {
    $controller = new FrontController($app);
    $controller->callAction('ayuda');
})->name('ayuda_view');
$app->get('/regUsuario', function () use($app) {
    $controller = new FrontController($app);
    $controller->callAction('regUsuario');
})->name('regUsuario_view');
$app->post('/regUsuario', function () use($app) {
    $controller = new UsuarioController($app);
    $controller->callAction('add');
})->name('addUserPost');
$app->get('/revisormaestro', function () use($app) {
    $controller = new FrontController($app);
Example #2
0
<?php

require 'core.php';
session_start();
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$checkaddress = function ($app, $need = true) {
    return function () use($app, $need) {
        if ($need) {
            if (empty($_SESSION['address'])) {
                $app->redirect($app->urlFor('root'));
            }
        } else {
            if (!empty($_SESSION['address'])) {
                $app->redirect($app->urlFor('faucet'));
            }
        }
    };
};
$checkclaim = function ($app) {
    return function () use($app) {
        global $dispenseTime, $recaptchaPub;
        $address = $_SESSION['address'];
        $ip = getIP();
        $sql = "SELECT dispensed FROM dispenses WHERE email='{$address}' OR ip='{$ip}' ";
        $sql .= "ORDER BY id DESC LIMIT 1";
        $lastclaim_query = sql_query($sql);
        $canclaim = true;
        if ($lastclaim_query->num_rows) {
            $lastclaim = fetch_one($lastclaim_query);
            $lastclaim = strtotime($lastclaim);
$app->configureMode('production', function () use($app) {
    $app->config(array('debug' => false, 'log.enabled' => true, 'log.level' => \Slim\Log::WARN));
});
/**
 * Handle the 404's
 * @param \Slim\Slim $app
 */
function notFoundHandler($app)
{
    $app->render('404.php', array(), 404);
}
// new visitor
$app->get('/', function () use($app) {
    $visitorService = Di::getInstance()['visitorService'];
    $id = $visitorService->storeNewVisitor($_SERVER);
    $url = $app->urlFor('viewer_route', array('id' => $id));
    $app->response->redirect($url, 302);
});
// returning visitor, shared link or source of redirect
$app->get('/me/:id', function ($id) use($app) {
    $visitorService = Di::getInstance()['visitorService'];
    $visitor = $visitorService->findByPublicID($id);
    if ($visitor) {
        $app->render('display.php', array('visitor' => $visitor));
    } else {
        notFoundHandler($app);
    }
})->name('viewer_route');
// update the javascript values
$app->post('/me/:id/js', function ($id) use($app) {
    $visitorService = Di::getInstance()['visitorService'];
Example #4
0
// Start the session
session_cache_limiter(false);
session_start();
// Composer autoloading (vendor and lib)
require '../app/vendor/autoload.php';
//app/lib/functions - load twig i18n extension
loadTwigi18n();
// Instantiate and configure Slim
$app = new \Slim\Slim(array('view' => new \Slim\Extras\Views\Twig()));
//register parse extensions (like twig) in the app
$app->view()->parserExtensions = array('Twig_Extension_Debug', 'Twig_Extensions_Extension_I18n');
//load environment specific config (slim settings, DB, globals and other)
require '../app/config/config.php';
//app/lib/functions - set locality
setLocality($config['defaultLocality']);
//load routes
require '../app/routes/api.php';
require '../app/routes/admin.php';
require '../app/routes/app.php';
if ($app->getMode() == "development") {
    require '../app/routes/test.php';
}
// route not found
$app->notFound(function () use($app) {
    // we need to override the default template
    $app->config('templates.path', './');
    $app->render('404.html', array('home' => $app->urlFor('home')));
    //it uses route alias 'home' from app.php route
});
// Run it
$app->run();
Example #5
0
 /**
  * @param SlimServiceMetadata $md
  * @param SlimServiceRegistration $endpoint
  * @param Slim\Slim $app
  */
 private static function EchoCommon(SlimServiceMetadata $md, $endpoint, Slim\Slim $app)
 {
     $response = $md->Response();
     echo "<h4>Name</h4>" . $md->Name();
     echo "<h4>Description</h4>" . str_replace("\n", "<br/>", $md->Description());
     echo '<h4>Route</h4>' . $app->urlFor($endpoint->RouteName());
     if ($endpoint->IsSecure()) {
         echo '<h4>This service is secure and requires authentication</h4>';
     }
     if ($endpoint->IsLimitedToAdmin()) {
         echo '<h4>This service is only available to application administrators</h4>';
     }
     echo '<h4>Response</h4>';
     if (is_object($response)) {
         echo '<div class="code">' . json_encode($response) . '</div>';
     } elseif (is_null($response)) {
         echo 'No response';
     } else {
         echo 'Unstructured response of type <i>' . $response . '</i>';
     }
 }
 /**
  * Test URL for
  */
 public function testSlimUrlFor()
 {
     $s = new \Slim\Slim();
     $s->get('/hello/:name', function () {
     })->name('hello');
     $this->assertEquals('/foo/hello/Josh', $s->urlFor('hello', array('name' => 'Josh')));
     //<-- Prepends physical path!
 }
Example #7
0
$app->get('/', function () use($app, $User, $Helper) {
    $app->render('home.php', array('app' => $app, 'User' => $User, 'Helper' => $Helper));
})->name('home');
$app->get('/p/:username', function ($username) use($app, $User) {
    $UserToView = new User();
    if ($UserToView->setName($username) && $UserToView->UserPublic) {
        $app->render('user.php', array('app' => $app, 'User' => $UserToView));
    } else {
        $app->render('userNotFound.php', array('app' => $app, 'User' => $User));
    }
})->name('user');
$app->get('/u/:type', function ($type) use($app, $User, $type, $Helper) {
    if (isset($_SESSION['isAuthed']) && $_SESSION['isAuthed']) {
        $users = $app->render('users.php', array('app' => $app, 'User' => $User, 'Users' => $Helper->listUsers()));
    } else {
        $app->redirect($app->urlFor('home'));
    }
})->name('users');
$app->get('/profile', function () use($app, $User) {
    if (isset($_SESSION['isAuthed']) && $_SESSION['isAuthed']) {
        $User->setName($_SESSION['UserName']);
        $app->render('profile.php', array('app' => $app, 'User' => $User));
    } else {
        $app->redirect($app->urlFor('home'));
    }
})->name('profile');
$app->get('/channels', function () use($app, $User) {
    if (isset($_SESSION['isAuthed']) && $_SESSION['isAuthed']) {
        $User->setName($_SESSION['UserName']);
        $locChannels = array();
        if (isset($User->UserChannels)) {
Example #8
0
//BASE 64 IMAGE UPLOAD
require_once 'func/security_csrf.php';
//SECURITY
require_once 'settings.php';
//SETTINGS
$app = new \Slim\Slim(array('cookies.encrypt' => COOKIECRYPT, 'cookies.secret_key' => COOKIEKEY, 'cookies.cipher' => MCRYPT_RIJNDAEL_256, 'cookies.cipher_mode' => MCRYPT_MODE_CBC));
$app->response->headers->set('Content-Type', 'application/json');
$app->group('/content', function () use($app) {
    $app->response->headers->set('Content-Type', 'application/json');
    $app->map('/get', function () use($app) {
        //if(isset($data->token) && security_token($token)){
        //if(security_token($token)){
        if ($app->getCookie('aco-lan') !== null) {
            $lan = $app->getCookie('aco-lan');
        } else {
            $app->redirect($app->urlFor('setLanguage', array('lan' => substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2))));
        }
        if ($app->getCookie('aco-user') !== null) {
            $app->redirect($app->urlFor('getModified'));
        } else {
            $app->redirect($app->urlFor('getFinished'));
        }
        /*}else{
              $app->halt(403, json_encode([   'type' => 'error',
                                              'title' => 'Forbidden Request',
                                              'message' => 'You do not have the permission to call this request.']));
          }*/
    })->via('GET', 'PUT', 'POST', 'DELETE')->name('getContent');
    $app->map('/get/finished', function () use($app) {
        if ($app->getCookie('aco-lan') !== null) {
            $lan = $app->getCookie('aco-lan');
Example #9
0
header('Content-type: text/html; charset=utf-8');
session_start();
require 'vendor/autoload.php';
$URL = "http://eontzia.zubirimanteoweb.com/";
// $URL="http://localhost/workspace/eontziApp/";
Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->config(array('debug' => true, 'templates.path' => 'Templates'));
//Raiz de /app
$app->map('/', function () use($app) {
    if (!isset($_SESSION['id_usuario'])) {
        //render login
        $app->render('tmp_login.php');
    } else {
        //enviar al inicio
        $app->redirect($app->urlFor('PaginaInicio'));
    }
})->via('GET')->name('Inicio');
$app->get('/inicio2', function () use($app) {
    $app->render('tmp_inicio2.php');
});
//Contacto
$app->post('/contacto', function () use($app) {
    include_once 'Modelos/CorreoUser.php';
    $req = $app->request();
    $nombre = trim($req->post('nombre'));
    $email = trim($req->post("correo"));
    $asunto = trim($req->post("asunto"));
    $comentarios = trim($req->post("comentario"));
    if (!isset($nombre) || !isset($email) || !isset($asunto) || !isset($comentarios)) {
        $mensaje = "con_ko_ef";
Example #10
0
<?php

################
# Конфигурация #
################
// временная зона
date_default_timezone_set('Europe/Moscow');
// Twig
$twig_view = new \Slim\Views\Twig();
$log_writer = new \Slim\LogWriter(fopen('log/slim_error.log', 'a'));
// общая конфигурация
$app = new \Slim\Slim(array('mode' => $ENV, 'view' => $twig_view, 'templates.path' => 'templates', 'upload.path' => 'uploads', 'log.writer' => $log_writer) + $config);
########
# Виды #
########
require_once 'views/lot.php';
require_once 'views/video.php';
require_once 'views/order.php';
require_once 'views/feedback.php';
// админ
$app->group('/admin', function () use($app) {
    require_once 'views/admin/lot.php';
    // редирект с главной
    $app->get('/', function () use($app) {
        $app->redirect($app->urlFor('lots'));
    });
    // данные для всех видов
    $app->view->appendData(array('project_title' => 'Biganto::Бэкенд', 'app' => $app));
});
Example #11
0
<?php

require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim(['debug' => true, 'templates.path' => 'templates/']);
$app->add(new \Slim\Middleware\SessionCookie(array('secret' => 'myappsecret')));
$authenticate = function ($app) {
    return function () use($app) {
        if (!isset($_SESSION['UserID'])) {
            $_SESSION['urlRedirect'] = $app->request()->getPathInfo();
            $app->flash('error', 'Login required');
            $app->redirect($app->urlFor('loginuser'));
        }
    };
};
$app->hook('slim.before.dispatch', function () use($app) {
    $UserID = null;
    if (isset($_SESSION['UserID'])) {
        $UserID = $_SESSION['UserID'];
    }
    $app->view()->setData('app', $app);
    $app->view()->setData('iUserID', $UserID);
});
$app->get('/', function () use($app) {
    $app->response->setStatus(200);
    $app->render('index.php');
});
include_once "adminrouting.php";
include_once "customerrouting.php";
$app->run();
<?php

require 'vendor/autoload.php';
require 'generated-conf/config.php';
$BASE = "de";
$app = new \Slim\Slim();
$app->get('/', function () use($BASE, $app) {
    $langs = \Base\PhrasebookCategoriesQuery::create()->select(array('lang'))->distinct()->find();
    $body = array();
    foreach ($langs as $lang) {
        if ($lang == $BASE) {
            continue;
        }
        $url = $app->urlFor("lang", array('lang' => $lang));
        array_push($body, array($lang => $url));
    }
    $body = array('language' => $BASE, 'translations' => $body);
    $app->response->header("content-type", "application/json");
    $app->response->body(json_encode($body, JSON_UNESCAPED_SLASHES));
})->name("root");
$app->get('/:lang', function ($lang) use($BASE, $app) {
    $catsBase = Base\PhrasebookCategoriesQuery::create()->filterByLang($BASE)->orderBy("id")->find();
    $categories = array();
    foreach ($catsBase as $catBase) {
        $id = $catBase->getId();
        $catLang = Base\PhrasebookCategoriesQuery::create()->findOneByIdAndLang($id, $lang);
        if ($catLang === NULL) {
            continue;
        }
        array_push($categories, array('id' => $catLang->getId(), $BASE => $catBase->getLabel(), $lang => $catLang->getLabel(), 'url' => $app->urlFor("category", array("lang" => $lang, "cat" => $catLang->getId()))));
    }
Example #13
0
    $recipe = $repo->getRecipe($name);
    $app->render('view_recipe.php', ['recipe' => $recipe]);
});
$app->post('/recipes/add', function () use($repo, $app) {
    $args = ['name' => trim(filter_var($_POST['name'], FILTER_SANITIZE_STRING)), 'ingredients' => array_map(function ($v) {
        return trim(filter_var($v, FILTER_SANITIZE_STRING));
    }, (array) $_POST['ingredients']), 'creator' => trim(filter_var($_POST['creator'], FILTER_SANITIZE_STRING))];
    $args = array_filter($args);
    $submit_ok = true;
    if (count($args) == 3) {
        $repo->addRecipe($args['name'], $args['ingredients'], $args['creator']);
    } else {
        $submit_ok = false;
    }
    if ($submit_ok) {
        $app->redirect($app->urlFor('recipe_list'));
    } else {
        $app->flash('form.name', $_POST['name']);
        $app->flash('form.ingredients', $_POST['ingredients']);
        $app->flash('form.creator', $_POST['creator']);
        $app->flash('form.submit_error', 'Save failed. This was probably because one or more fields were empty.');
        $app->redirect($app->urlFor('recipe_add'));
    }
})->name('recipe_add');
$app->get('/json', function () use($repo, $app) {
    $contents = json_encode($repo->getAllRecipes());
    $app->response->headers->set('Content-Description', 'File Transfer');
    $app->response->headers->set('Content-Type', 'application/json');
    $app->response->headers->set('Content-Disposition', 'attachment; filename="recipes.txt"');
    $app->response->headers->set('Content-Length', strlen($contents));
    $app->response->headers->set('Expires', '0');
Example #14
0
$app->view()->parserOptions = array('cache' => __DIR__ . '/cache');
$app->view()->parserExtensions = array(new \Slim\Views\TwigExtension(), new DisposableEmail\AutoLinkTwigExtension());
// add html2Text filter
$app->view()->getInstance()->addFilter(new Twig_SimpleFilter('html2Text', function ($string) {
    $convert = new \Html2Text\Html2Text($string);
    return $convert->get_text();
}));
// redirect to random address
$app->get('/', function () use($app) {
    $wordLength = rand(3, 8);
    $container = new PronounceableWord_DependencyInjectionContainer();
    $generator = $container->getGenerator();
    $word = $generator->generateWordOfGivenLength($wordLength);
    $nr = rand(51, 91);
    $name = $word . $nr;
    $app->redirect($app->urlFor('read', array('name' => $name)));
})->name('home');
// switch to other account using form
$app->post('/switch', function () use($app) {
    $name = cleanName($app->request->params('name'));
    if (strlen($name) == 0) {
        $app->redirect($app->urlFor('home'));
    }
    $app->redirect($app->urlFor('read', array('name' => $name)));
})->name('switch');
// ajax check to see if there is new mail
$app->get('/check/:name', function ($name) use($app, $mailbox) {
    $name = cleanName($name);
    $mailsIds = findMails($name, $mailbox);
    print sizeOf($mailsIds);
})->name('mailcount');
Example #15
0
    $app->render('configuration.html');
});
$app->get('/info', function () use($app) {
    $app->render('info.php');
});
//Login
$app->post('/login', function () use($app) {
    require_once 'Modelo/Usuario.php';
    $mensaje = "val_OK";
    $app->redirect($app->urlfor('resultado', array('mensaje' => $mensaje)));
    $usr = $app->request->post('idUsuario');
    $pass = $app->request->post('pass');
    if (isset($usr) && isset($pass)) {
        $result = Usuario::comprobarUsuario($usr, $pass);
        if ($result == 1) {
            $app->redirect($app->urlFor('Inicio'));
        } else {
            if ($result == 0) {
                $app->flash('message', "No existe el usuario");
                $app->redirect($app->urlFor('Inicio'));
            } else {
                $app->flash('message', "El usuario no está validado, valida para poder acceder.");
                $app->redirect($app->urlFor('Inicio'));
            }
        }
    } else {
        $app->flash('message', "Faltan datos por introducir.");
        $app->redirect($app->urlFor('Inicio'));
    }
});
//Registro usuario
Example #16
0
 if ($resConsulta) {
     $resConsulta = $dbManejador->realizarConsulta("SELECT fecha FROM pass WHERE matricula = '" . $_SESSION["usuario"] . "' AND password = sha1('{$passNueva}')");
     if ($resConsulta) {
         echo "La contrasenia ya existe en el historial";
     } else {
         $resConsulta = $dbManejador->realizarConsulta("SELECT password, fecha FROM pass WHERE matricula= '" . $_SESSION["usuario"] . "' ORDER BY fecha DESC LIMIT 3");
         if (count($resConsulta) >= 3) {
             $resConsulta = $dbManejador->realizarAccion("DELETE FROM pass WHERE matricula= '" . $_SESSION["usuario"] . "' ORDER BY fecha ASC LIMIT 1");
         }
         $resConsulta = $dbManejador->realizarAccion("INSERT INTO pass VALUES('" . $_SESSION["usuario"] . "', sha1('{$passNueva}'), NOW())");
         echo "La contrase;a fue cambiada correctamente";
     }
 } else {
     echo "No existe la contrasenia actual";
 }
 echo "<br><a href='" . $app->urlFor("inicio") . "'> Regresar </a>";
 /* $consultaResultante = $bd->prepare("SELECT matricula FROM pass WHERE password=sha1('$passActual') AND matricula='".               $_SESSION["usuario"] ."';");
     $consultaResultante->execute();
    if($consultaResultante->rowCount()>0){
         $consultaResultante = $bd->prepare("SELECT matricula FROM pass WHERE password=sha1('$passNueva') AND matricula='".                 $_SESSION["usuario"] ."';");
         $consultaResultante->execute();
         if($consultaResultante->rowCount() == 0){
             $consultaResultante = $bd->prepare("SELECT fecha from pass where matricula='". $_SESSION["usuario"] ."' ORDER BY fecha                   ASC LIMIT 1;");
             $consultaResultante->execute();
             $consultaResultante2= $bd->prepare("DELETE FROM pass WHERE matricula='". $_SESSION["usuario"] ."' AND                                     fecha='$consultaResultante';");
             $consultaResultante2->execute();
         }
     }else {
         $consultaResultante = $bd->prepare("INSERT INTO pass(password) values('$passNueva')");
         $consultaResultante->execute(); 
         if($consultaResultante){
$app = new \Slim\Slim(array('view' => new \Slim\Views\Twig()));
$app->config = (require __DIR__ . '/app/config/config.php');
$app->add(new \Slim\Middleware\SessionCookie(array()));
$em = new EM($app);
$em = $em->getEntityManager();
/*****************/
/****** WEB ******/
/*****************/
$app->get('/', function () use($app, $twig) {
    echo $twig->render('index.php', array('flash' => isset($_SESSION['slim.flash']) ? $_SESSION['slim.flash'] : null));
})->name('home');
$app->get('/like/:path', function ($path) use($app, $twig, $em) {
    $vote = $app->getCookie("{$path}");
    if ($vote) {
        $app->flash('danger', "Vous avez déjà liké.");
        $app->redirect($app->urlFor('home', array()));
    } else {
        $qr = $em->getRepository("App\\Entity\\QRCode")->findOneBy(array('path' => $path));
        if ($qr == null) {
            $app->notFound();
        }
        $qr->increment();
        $cl = new ClickLog();
        $em->persist($cl);
        $qr->addClickLog($cl);
        $em->persist($qr);
        $em->flush();
        $app->setCookie("{$path}", true);
        //Render
        $title = $qr->getTitle();
        $counter = $qr->getCounter();
Example #18
0
 public function GetServiceUrl($serviceName, $params = array())
 {
     return $this->slim->urlFor($serviceName, $params);
 }
Example #19
0
<?php

require '../bootstrap.php';
// Prepare app
$app = new \Slim\Slim(require '../config.php');
// Define routes
$app->get('/', function () use($app) {
    $app->render('home.tpl.php', array('action' => $app->urlFor('home'), 'rootUri' => $app->request()->getRootUri()));
})->name('home');
$app->post('/', function () use($app) {
    $url = trim($app->request()->post('url'));
    if ($url && str_start_with(JIANSHU, $url)) {
        if (str_start_with(JIANSHU_RECOMMENDATIONS_NOTES, $url)) {
            $app->redirect($app->urlFor('feeds.recommendations'));
        } elseif (str_start_with(JIANSHU_ALL_NOTES, $url) || str_start_with(JIANSHU_TIMELINE_NOTES, $url)) {
            $app->redirect($app->urlFor('feeds.latest'));
        } elseif (str_start_with(JIANSHU_COLLECTIONS_ROOT, $url)) {
            $app->redirect($app->urlFor('feeds.collections', array('id' => substr($url, strlen(JIANSHU_COLLECTIONS_ROOT)))));
        } elseif (str_start_with(JIANSHU_NOTEBOOKS_ROOT, $url)) {
            $id = substr($url, strlen(JIANSHU_NOTEBOOKS_ROOT));
            if (($pos = strpos($id, '/')) !== false) {
                $id = substr($id, 0, $pos);
            }
            $app->redirect($app->urlFor('feeds.notebooks', array('id' => $id)));
        } elseif (str_start_with(JIANSHU_USERS_ROOT, $url)) {
            $id = substr($url, strlen(JIANSHU_USERS_ROOT));
            if (($pos = strpos($id, '/')) !== false) {
                $id = substr($id, 0, $pos);
            }
            $app->redirect($app->urlFor('feeds.users', array('id' => $id)));
        } else {
Example #20
0
                $school->save();
                $data['new_school'] = $school->toArray();
            }
        }
        $app->render('schools/edit.html', $data);
    })->via('GET', 'POST')->name('schools_edit');
});
$app->map('/login', function () use($app) {
    $data = array();
    if ($app->request->isPost()) {
        $auth = wp_authenticate_username_password(NULL, $app->request->post('username'), $app->request->post('password'));
        if (is_wp_error($auth)) {
            $data['error'] = 'Gebruikersnaam of wachtwoord is fout';
        } else {
            $_SESSION['loggedin'] = true;
            $app->redirect($app->urlFor('dashboard'));
        }
    }
    $app->render('login.html', $data);
})->via('GET', 'POST')->name('login');
$app->get('/logout', function () use($app) {
    session_destroy();
    $app->redirect($app->urlFor('login'));
})->name('logout');
if (!isset($_SESSION['loggedin']) || $_SESSION['loggedin'] == false) {
    if ($app->request->getResourceUri() != '/login') {
        try {
            $app->redirect($app->urlFor('login'));
        } catch (Exception $e) {
        }
    }
    $statusModified = true;
    $status['reference'] = $ref;
}
$app = new \Slim\Slim();
$app->config('debug', false);
$app->view(new \JsonApiView());
$app->add(new \JsonApiMiddleware());
$app->group('/results', function () use($app) {
    $app->post('/', function () use($app) {
        global $status, $statusModified;
        // Create a new session
        $session = Session::createSession($status['results']);
        $status['results']++;
        $statusModified = true;
        $sessionInfo = $session->getInfo();
        $sessionInfo['href'] = $app->urlFor('results', array('id' => $session->id));
        Notify(ADMIN_TOPIC, array('action' => 'create', 'session' => $sessionInfo));
        $app->render(200, array('session' => $sessionInfo));
    });
    $app->get('/', function () use($app) {
        $sessions = array();
        if ($dh = opendir(SESSION_DIR)) {
            while (($file = readdir($dh)) !== false) {
                if (Session::isValidSession($file)) {
                    $session = new Session($file);
                    $sessionInfo = $session->getInfo();
                    $sessionInfo['href'] = $app->urlFor('results', array('id' => $file));
                    array_push($sessions, $sessionInfo);
                }
            }
            closedir($dh);
Example #22
0
<?php

require __DIR__ . '/utility.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->notFound(function () use($dati, $app) {
    $app->render('shared/404.php', array('dati' => $dati));
});
$app->get('/', function () use($dati, $app) {
    $app->render('index.php', array('dati' => $dati));
})->name('index');
$app->map('/contattaci', function () use($dati, $app) {
    $app->render('email.php', array('dati' => $dati));
    if (fatto()) {
        $app->redirect($app->urlFor('index'));
    }
})->via('GET', 'POST');
$app->map('/templates(/:name+)', function ($name) use($dati, $app) {
    $app->render('shared/404.php', array('dati' => $dati));
})->via('GET', 'POST');
$app->get('/guida/:id', function ($id) use($dati, $app) {
    $app->render('index.php', array('dati' => $dati, 'guida' => $id));
});
$app->get('/logout', function () use($dati, $app) {
    $app->render('login/logout.php', array('dati' => $dati));
    $app->redirect($app->urlFor('index'));
});
if (!$dati['debug'] || isAdminUserAutenticate()) {
    $app->map('/login', function () use($dati, $app) {
        $app->render('login/index.php', array('dati' => $dati));
        if (isUserAutenticate()) {
Example #23
0
/*
ORM::configure('mysql:host=localhost;dbname=bd2015');
ORM::configure('username', 'root'); // estos datos poner en archivo configuracion
ORM::configure('password', 'root'); // estos datos poner en archivo configuracion
	$plato = ORM::for_table('rest_plato')
		->where('id', $id)
		->find_one();
	$platos = ORM::for_table('rest_plato')
		->limit($pag+5)->offset($pag*5)->find_many(); // el limite de 5 elementos poner en archivo configuracion
*/
$app->get('/', function () use($app, $twig) {
    //comprobar login
    /*
    $app->redirect('./login');
    */
    $url = $app->urlFor('login');
    $app->redirect($url);
    //return $twig->render('index.html.twig');
    $template = $twig->loadTemplate('index.html.twig');
    echo $template->render(array());
})->name('index');
$app->get('/login', function () use($app, $twig) {
    //comprobar login
    /*
    $app->redirect('./index');
    */
    /*
    $url = $app->urlFor('index');
    $app->redirect($url);
    */
    $template = $twig->loadTemplate('login.html.twig');