$app->group('/subscribers', function () use($app) {
     $app->get('(/(:page))', 'validateUser', function ($page = 1) use($app) {
         $s = new Subscriptions('');
         $start = getPaginationStart($page);
         $count = $s->countSubscriptions();
         $number_of_pages = ceil($count / LIMIT);
         $users = $s->getAllSubscriptions($start);
         $app->render(ADMIN_THEME . 'subscribers.php', array('users' => $users, 'number_of_pages' => $number_of_pages, 'current_page' => $page, 'count' => $count, 'page_name' => 'subscribers'));
     });
     $app->get('/:id/:action/:token', 'validateUser', function ($id, $action, $token) use($app) {
         $s = new Subscriptions('');
         $user = $s->getUserSubscription($id, $token);
         if (isset($user)) {
             switch ($action) {
                 case 'approve':
                     $s->updateSubscription($id, ACTIVE);
                     $app->flash('success', 'User subscription is confirmed.');
                     break;
                 case 'deactivate':
                     $s->updateSubscription($id, INACTIVE);
                     $app->flash('success', 'User subscription has been deactivated.');
                     break;
                 case 'delete':
                     $s->deleteSubscription($id, $token);
                     $app->flash('success', 'User subscription has been deleted.');
                     break;
             }
         }
         $app->redirect(ADMIN_URL . 'subscribers');
     });
 });
        if ($data['trap'] == '') {
            $subscribe = new Subscriptions($data['email'], $data['category_id'], $data['city_id']);
            if ($subscribe->createSubscription($subscription_for)) {
                $app->flash('success', "A subscription confirmation was sent to your email address.");
            } else {
                $app->flash('danger', "Your subscription failed. You may have an existing subscription already.");
            }
            $app->redirect(BASE_URL . "{$redirect}/{$id}");
        } else {
            $app->flash('danger', "Your subscription failed. You are not allowed to subscriibe.");
            $app->redirect(BASE_URL . "{$redirect}/{$id}");
        }
    });
    $app->get('/:id/:action/:token', 'isBanned', function ($id, $action, $token) use($app) {
        $status = $action == 'confirm' ? ACTIVE : INACTIVE;
        $s = new Subscriptions('');
        $user = $s->getUserSubscription($id, $token);
        if ($user) {
            $s->updateSubscription($id, $status);
            if ($status == ACTIVE) {
                $app->flash('success', 'Thank you for confirming your subscription.');
            } else {
                $app->flash('success', 'Your subscription has been canceled.');
            }
            $app->redirect(BASE_URL);
        } else {
            $app->flash('danger', 'Your subscription could not be confirmed.');
            $app->redirect(BASE_URL);
        }
    });
});