Ejemplo n.º 1
0
 public function parseUrl()
 {
     $routes = $this->loadAllRoutes();
     $valid = false;
     $requestUrl = $_GET['url'];
     if ($requestUrl[strlen($requestUrl) - 1] === '/' && substr_count($requestUrl, '/') > 1) {
         $requestUrl = substr($requestUrl, 0, strlen($requestUrl) - 1);
     }
     foreach ($routes as $routeInfo) {
         $routeString = $routeInfo['methodPattern'];
         preg_match("/\\A{$routeString}\\z/", $requestUrl, $test);
         if (count($test) > 0 && $_SERVER['REQUEST_METHOD'] === $routeInfo['requestType']) {
             $this->routeInfo = $routeInfo;
             $this->controller = $routeInfo['controller'];
             $this->action = $routeInfo['action'];
             $valid = true;
             if (count($test) > 1) {
                 for ($i = 1; $i < count($routeInfo['parameters']) + 1; $i++) {
                     $this->routeParams[] = $test[$i];
                 }
             }
             break;
         }
     }
     if ($valid === false) {
         RouteService::redirect('home', '404', [], true);
     }
 }
 public function register()
 {
     if ($this->isLogged()) {
         RouteService::redirect('account', 'profile', true);
     }
     return new View("user\\register", []);
 }
 /**
  * @Roles(Administrator, Editor)
  * @Route("{id:num}/delete")
  */
 public function delete($id)
 {
     $isDeleted = $this->eshopData->getCategoriesRepository()->remove($id);
     if ($isDeleted) {
         RouteService::redirect('categories', '', true);
     } else {
         echo 'Error during delete category';
     }
 }
 public function dispatch()
 {
     if (!isset($_GET['url'])) {
         RouteService::redirect('home', '', [], true);
     }
     try {
         $this->initRequest();
         $this->getRouter()->parseUrl();
         $this->initController();
         $this->invokeTheRoute();
     } catch (\Exception $e) {
         echo $e->getMessage();
         return false;
     }
 }
Ejemplo n.º 5
0
<section id="form"><!--form-->
    <div class="container">
        <div class="row">
            <div class="col-sm-4 col-sm-offset-4">
                <div class="signup-form"><!--sign up form-->
                    <h2>New User Signup!</h2>
                    <?php 
echo \DF\Helpers\ViewHelpers\FormViewHelper::init()->initTextField()->setName('username')->setAttribute('placeholder', 'Username')->create()->initPasswordField()->setName('password')->setAttribute('placeholder', 'Password')->create()->initPasswordField()->setName('confirmPassword')->setAttribute('placeholder', 'Confirm Password')->create()->initTextField()->setName('email')->setAttribute('placeholder', 'Email')->create()->initSubmitButton()->setValue('Register')->setAttribute('class', 'btn btn-default')->create()->setAction(\DF\Services\RouteService::getUrl('account', 'register'))->setMethod('POST')->render();
?>
                </div><!--/sign up form-->
            </div>
        </div>
    </div>
</section>
                        <span class="icon-bar"></span>
                    </button>
                </div>
                <div class="mainmenu pull-left">
                    <ul class="nav navbar-nav collapse navbar-collapse">
                        <li><a href="<?php 
echo \DF\Services\RouteService::getUrl('home', '');
?>
" class="active">Home</a></li>
                        <li class="dropdown"><a href="#">Shop<i class="fa fa-angle-down"></i></a>
                            <ul role="menu" class="sub-menu">
                                <li><a href="<?php 
echo \DF\Services\RouteService::getUrl('categories', '');
?>
">Categories</a></li>
                                <li><a href="<?php 
echo \DF\Services\RouteService::getUrl('home', 'login');
?>
">Login</a></li>
                                <li><a href="<?php 
echo \DF\Services\RouteService::getUrl('home', 'register');
?>
">Register</a></li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
Ejemplo n.º 7
0
<div class="container text-center">
    <div class="content-404">
        <img src="../Content/images/404/404.png" class="img-responsive" alt="" />
        <h1><b>OPPS!</b> We Couldn’t Find this Page</h1>
        <p>Uh... So it looks like you brock something. The page you are looking for has up and Vanished.</p>
        <h2><a href="<?php 
echo \DF\Services\RouteService::getUrl('home', '');
?>
">Bring me back Home</a></h2>
    </div>
</div>
Ejemplo n.º 8
0
<section id="form"><!--form-->
    <div class="container">
        <div class="row">
            <div class="col-sm-4 col-sm-offset-4">
                <div>
                    <h2>Ban user</h2>
                    <?php 
echo \DF\Helpers\ViewHelpers\FormViewHelper::init()->initTextField()->setName('username')->setAttribute('placeholder', 'Username')->create()->initSubmitButton()->setValue('BAN')->setAttribute('class', 'btn btn-default')->create()->setAction(\DF\Services\RouteService::getUrl('admin', 'banuser'))->setMethod('POST')->render();
?>

                    <h2>Ban IP</h2>
                    <?php 
echo \DF\Helpers\ViewHelpers\FormViewHelper::init()->initTextField()->setName('IP')->setAttribute('placeholder', 'Ip address')->create()->initSubmitButton()->setValue('BAN')->setAttribute('class', 'btn btn-default')->create()->setAction(\DF\Services\RouteService::getUrl('admin', 'banip'))->setMethod('POST')->render();
?>
                </div>
            </div>
        </div>
    </div>
</section>
Ejemplo n.º 9
0
 private function initRouteService()
 {
     $phpSelf = $_SERVER['PHP_SELF'];
     $index = basename($phpSelf);
     RouteService::init(str_replace($index, '', $phpSelf));
 }
 /**
  * @POST
  * @Roles(Administrator, Editor)
  * @Route("{id:num}")
  */
 public function changeCategory($id, ChangeProductCategoryBindingModel $model)
 {
     $result = $this->eshopData->getProductsRepository()->changeCategory($id, $model->getCategoryId());
     RouteService::redirect('products', '', [$id], true);
 }
 /**
  * @Authorize
  */
 public function logout()
 {
     if ($this->isLogged()) {
         Session::emptyUserRelated();
         RouteService::redirect('home', '', true);
     }
 }
Ejemplo n.º 12
0
<div class="col-sm-9 padding-right">
    <div class="features_items"><!--features_items-->
        <h2 class="title text-center">Features Items</h2>
        <?php 
if (\DF\Services\RoleService::isAdministrator() || \DF\Services\RoleService::isEditor()) {
    ?>
        <form action="<?php 
    echo \DF\Services\RouteService::getUrl('products', '');
    ?>
" method="POST">
            <input type="text" name="productName" placeholder="name">
            <input type="text" name="productPrice" placeholder="price">
            <input type="text" name="categoryId" placeholder="category id">
            <input type="text" name="quantity" placeholder="quantity">
            <input type="hidden" name="csrf_token" value="<?php 
    echo \DF\Helpers\Csrf::getCSRFToken();
    ?>
">
            <input type="submit" value="Add Product">
        </form>
        <?php 
}
?>
        <?php 
foreach ($model->products as $product) {
    ?>
        <div class="col-sm-4">
            <div class="product-image-wrapper">
                <div class="single-products">
                    <div class="productinfo text-center">
                        <img src="images/home/product1.jpg" alt="" />
 /**
  * @POST
  * @Roles(Administrator)
  */
 public function banip(BanIpBindingModel $model)
 {
     $this->eshopData->getUsersRepository()->banIP($model->getIpAddress());
     RouteService::redirect('admin', 'ban', [], true);
 }
Ejemplo n.º 14
0
<div class="header-middle">
    <div class="container">
        <div class="row">
            <div class="col-sm-4">

            </div>
            <div class="col-sm-8">
                <div class="shop-menu pull-right">
                    <ul class="nav navbar-nav">
                        <li><a href="#"><i class="fa fa-user"></i> Account</a></li>
                        <li><a href="<?php 
echo \DF\Services\RouteService::getUrl('account', 'cart');
?>
"><i class="fa fa-shopping-cart"></i> Cart</a></li>
                        <li><a href="<?php 
echo \DF\Services\RouteService::getUrl('account', 'products');
?>
"><i class="fa fa-shopping-cart"></i> My products</a></li>
                        <li><a href="<?php 
echo \DF\Services\RouteService::getUrl('account', 'logout');
?>
"><i class="fa fa-lock"></i> Logout</a></li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
</div>
    <div class="left-sidebar">
        <h2>Category</h2>
        <div class="panel-group category-products" id="accordian"><!--category-productsr-->
            <div class="panel panel-default">
                <?php 
if (\DF\Services\RoleService::isAdministrator() || \DF\Services\RoleService::isEditor()) {
    echo \DF\Helpers\ViewHelpers\FormViewHelper::init()->setMethod('POST')->setAction(\DF\Services\RouteService::getUrl('categories', ''))->initTextField()->setName('name')->create()->initSubmitButton()->setValue("Add")->create()->render();
}
?>
                <?php 
foreach ($model->categories as $category) {
    ?>
                <div class="panel-heading">
                    <h4 class="panel-title">
                        <a href="<?php 
    echo \DF\Services\RouteService::getUrl('categories', '', [$category['id']]);
    ?>
"><?php 
    echo $category['name'];
    ?>
</a>
                        <?php 
    if (\DF\Services\RoleService::isAdministrator() || \DF\Services\RoleService::isEditor()) {
        ?>
                        <a class="cart_quantity_delete" href="<?php 
        echo \DF\Services\RouteService::$basePath . "categories/" . $category['id'] . "/delete";
        ?>
"><i class="fa fa-times"></i></a>
                         <?php 
    }
    ?>