示例#1
0
 /**
  * @param Request $request
  * @return string|null
  */
 private function getTokenFromRequest(Request $request)
 {
     $token = $request->getPostVal($this->tokenFieldName);
     if ($token !== null) {
         return $token;
     }
     return $request->getGetVal($this->tokenFieldName);
 }
示例#2
0
 /**
  * Initialize all the property controller needed.
  */
 protected function initialize()
 {
     $this->game = new Game();
     $this->request = new Request();
     $this->battleshipView = new View\Battleship();
     $this->game->initialize();
     $this->request->createForm('/index.php');
 }
示例#3
0
 /**
  * @param Request $request
  * @return PartialHtmlResponse
  */
 public function run(Request $request)
 {
     $urlBuilder = $this->serviceContainer->getUrlBuilder();
     $editUrl = $this->serviceContainer->getTemplateBuilder()->createTemplate();
     $userUrlLoader = $this->serviceContainer->getUserUrlLoader();
     $csrfHandler = $this->serviceContainer->getCsrfHandler()->createNewToken();
     $url = $userUrlLoader->loadUrl($request->getGetVal('id'));
     if ($url == null) {
         return new PartialHtmlResponse('Sorry, you are not allowed to edit this url.');
     }
     $update_action_url = $urlBuilder->createActionUrl('updateUrl', $request->getGetVal('id'));
     $trash_link = $urlBuilder->createActionUrl('trashUrl', $url->getId(), $csrfHandler->getCurrentToken());
     $editUrl->loadFile('editUrl.html')->addPlaceHolder('form_action', $update_action_url)->addPlaceHolder('url', $url->getUrl())->addPlaceHolder('title', $url->getTitle())->addPlaceHolder('description', $url->getDescription())->addPlaceHolder('trash_link', $trash_link)->addPlaceHolder('list_urls_link', $urlBuilder->createActionUrl('listUrls'))->addCsrfToken($csrfHandler);
     return new PartialHtmlResponse($editUrl->render());
 }
示例#4
0
 public function index()
 {
     $twig = Config::getTwig();
     $productId = Request::_request('productId');
     $productDetail = \model\ProductList::getProduct($productId);
     //die( $productDetail) ;
     /*if (isset($_GET['marketId'])){
                 $marketId = $_GET['marketId'];
     
                 // ##########################################
                 // ##########################################
                 // -- ** --
                 // Burada market sayfası için gerekli diğer sorgular yapılacaktır
                 // - section Listesi
                 // - genel ürün listesi (çok satılan vs)
                 // - (+) diğer istekler
                 // ##########################################
                 // ##########################################
     
                 $sectionList = \model\GuppyFunctions::prepareCategoryMenu();
             }*/
     $result = array('productDetail' => json_decode($productDetail)->content);
     //$result = array('products' => $productList);
     return $twig->render('client/product_detail2.html', $result);
 }
示例#5
0
 /**
  * Sayfa için cache id oluşturur
  *
  * @return string
  */
 private function getCacheId($ip)
 {
     if ($ip == null) {
         return Cryptography::sha(Request::_session('tc_kimlik_no') . __CLASS__ . $this->criteria['page']);
     } else {
         return Cryptography::sha(Header::getIpAddress() . __CLASS__ . $this->criteria['page']);
     }
 }
示例#6
0
 /**
  * session atan method.
  * Session için array olarak giden parametredeki
  * tüm değerleri session olarak atar
  * array('name'=>'Mehmet')
  *
  * @param Array $sessionArr
  * @return boolean
  */
 public static function createSession(array $sessionArr)
 {
     if (is_array($sessionArr)) {
         foreach ($sessionArr as $name => $value) {
             $_SESSION[Request::addslashes_array($name)] = $value;
         }
         return true;
     }
     return false;
 }
示例#7
0
 /**
  * url array set eder
  *  
  * @param array $urlArr
  * @return string
  */
 public static final function setURL($urlArr)
 {
     if (!isset($urlArr['page'])) {
         $urlArr = array_merge(['page' => Request::_get('page')], $urlArr);
     }
     if (Config::REWRITE) {
         return '/' . self::arrayToUrl($urlArr);
     } else {
         return '/index.php?' . self::arrayToUrl($urlArr);
     }
 }
 /**
  * @param Request $request
  * @return PartialHtmlResponse
  */
 public function run(Request $request)
 {
     $userName = $request->getPostVal('user');
     $password = $request->getPostVal('password');
     $urlBuilder = $this->serviceContainer->getUrlBuilder();
     $passwordVerifier = $this->serviceContainer->getPasswordVerifier();
     $userSession = $this->serviceContainer->getUserSession();
     $csrfHandler = $this->serviceContainer->getCsrfHandler();
     if ($csrfHandler->requestIsValid($request) == false) {
         return new CompleteHtmlResponse($csrfHandler->getErrorMessage());
     }
     $user = $this->getUserByName($userName);
     if ($user == null) {
         return new HttpRedirectResponse($urlBuilder->createActionUrl('login'));
     }
     if ($passwordVerifier->verifyUserPassword($user, $password)) {
         $userSession->loginAs($user->getId(), $user->getName());
     } else {
         return new HttpRedirectResponse($urlBuilder->createActionUrl('login'));
     }
     return new HttpRedirectResponse($urlBuilder->createActionUrl('listUrls'));
 }
示例#9
0
 public function index()
 {
     $twig = Config::getTwig();
     //-- Get Distrubuter  -- //
     $distrName = Request::_get('id');
     $categoryList = Category::getCategoryTree()->content;
     //-- Get Main Categories -- //
     $maincategoryList = $categoryList->childList;
     //-- Define Rendered Result -- //
     $result = array('categoryList' => $maincategoryList, 'distrName' => $distrName);
     //-- Render Result -- //
     return $twig->render('home.html', $result);
 }
示例#10
0
 /**
  * @param Request $request
  * @param int $user_id
  * @return UrlDataObject
  */
 public function mapToDataObject(Request $request, $user_id)
 {
     $urlDataObject = new UrlDataObject();
     $urlDataObject->userId = $user_id;
     $urlDataObject->id = $request->getGetVal('id');
     $urlDataObject->url = $request->getPostVal('url');
     $urlDataObject->title = $request->getPostVal('title');
     $urlDataObject->description = $request->getPostVal('description');
     $urlDataObject->created = $request->getPostVal('created');
     $urlDataObject->updated = $request->getPostVal('update');
     return $urlDataObject;
 }
示例#11
0
 public function index()
 {
     // -- ** -- GET Twig & city list
     $twig = Config::getTwig();
     $loginResult = Order::getOrder(Request::_get("id"));
     //die($_SERVER['REQUEST_URI']);
     // -- ** -- Check $cityList content is exist with isset method
     $result = array('order' => $loginResult->content);
     // -- ** -- Render result with twig
     if ($loginResult->isSuccess()) {
         return $twig->render('admin/pages/examples/invoice.html', $result);
     } else {
         return $twig->render('admin/pages/examples/invoice.html', $result);
     }
 }
示例#12
0
 public function index()
 {
     // -- ** -- GET Twig & city list
     $twig = Config::getTwig();
     #$loginResult = ProductList::getAllProducts();
     //die($_SERVER['REQUEST_URI']);
     $brands = Brand::getBrands();
     $sections = Section::getSections();
     if (Request::_request_post('product_name')) {
         $array["do"] = "addProduct";
         if (Request::_request_post("product_brand")) {
             $array['brand_id'] = Request::_request_post("product_brand");
         }
         $array['name'] = Request::_request_post("product_name");
         if (Request::_request_post("product_code")) {
             $array['barcode'] = Request::_request_post("product_code");
         }
         if (Request::_request_post("product_desc")) {
             $array['desc'] = Request::_request_post("product_desc");
         }
         if (Request::_request_post("product_section")) {
             $array['section_id'] = Request::_request_post("product_section");
         }
         if ($_FILES["product_image"]) {
         } else {
             echo "lkşkşki";
         }
         $array["admin_id"] = "123459";
         $res = ProductDetail::addProduct($array);
         if ($res->isSuccess()) {
             $result = array('addProductSuccess' => true, 'brands' => json_decode($brands)->content, 'sections' => json_decode($sections)->content);
         } else {
             $result = array('addProductFailure' => true, 'brands' => json_decode($brands)->content, 'sections' => json_decode($sections)->content);
         }
         return $twig->render('admin/pages/forms/general2.html', $result);
     } else {
         $prod = ProductList::getProduct(Request::_get("id"));
         if ($prod->isSuccess()) {
             $result = array('brands' => json_decode($brands)->content, 'sections' => json_decode($sections)->content, 'product' => $prod->content);
         } else {
             $result = array('brands' => json_decode($brands)->content, 'sections' => json_decode($sections)->content);
         }
         return $twig->render('admin/pages/forms/product.html', $result);
     }
 }
示例#13
0
 /**
  *
  * @param int $errno
  * @param string $errmsg
  * @param string $filename
  * @param int $linenum
  * @param string $vars
  * @param boolean $redirect
  * @return void
  */
 public static function errorHandler($errno, $errmsg, $filename, $linenum, $vars, $redirect = true)
 {
     if (is_integer($errno) && ($errno > E_NOTICE || $errno == 1)) {
         $host = self::getHostName();
         $time = microtime(true) - (double) \model\Request::_session('microtime');
         $arr = debug_backtrace();
         $len = count($arr);
         for ($i = 0; $i < $len; $i++) {
             $arr[$i]['args'][4] = array();
         }
         $paramArr = array('islemKodu' => 'ekle', 'ip_address' => Header::getIpAddress(), 'url' => $_SERVER['REQUEST_URI'], 'get' => json_encode($_GET), 'post' => json_encode($_POST), 'session' => json_encode($_SESSION), 'cookie' => json_encode($_COOKIE), 'execute_time' => $time, 'server_ip' => $_SERVER['SERVER_ADDR'], 'error_no' => $errno, 'message' => $errmsg, 'file' => $filename, 'line' => $linenum, 'host' => $host, 'error_data' => json_encode($arr), 'parameters' => json_encode(Listener::getInstance()->parameters));
         $CURL = new Curl(Config::JSON_URL . '/EDV03_PORTAL_PHPError/PhpErrorJSON', $paramArr);
         $CURL->getArray();
         if ($redirect) {
             Header::redirect(Config::ERROR_URL);
         }
     }
 }
示例#14
0
 /**
  * formda hatalı giriş yapıldığında hata mesajı çıkartmak için kullanılır
  *
  * @param string $fieldName
  * @param string $message
  * @return void
  */
 public static function addFieldErrorMessage($fieldName, $message)
 {
     $sessionArr = (array) Request::_session(self::ERROR_FORM_MESSAGE_NAME);
     $arr = array(self::ERROR_FORM_MESSAGE_NAME => array_merge($sessionArr, array($fieldName => $message)));
     Session::createSession($arr);
 }
示例#15
0
 private static function getPath()
 {
     $url = (string) Request::_get('page');
     foreach (ResourceBundle::GUPPYPAGELINKS as $link) {
         if ($url == $link['url']) {
             return array('kod' => 0, 'page' => $url, 'runPHPFile' => $link['link']);
         }
     }
     return array('kod' => 1);
 }
示例#16
0
 public function index()
 {
     $distributerList = DistributerModal::getDistibuterList(Request::_get('dist'));
     return Config::getTwig()->render('client/dummy_place_select.html', array('distributerList' => json_decode($distributerList)->content));
 }
示例#17
0
 /**
  * construct method
  *
  * @param array $criteria
  */
 public function __construct(array &$criteria)
 {
     $this->criteria = Request::addslashes_array($criteria);
     //$this->SMARTY =& Loader::loadClass('Smarty');
     $this->formDataArr = (array) Request::_session(FormData::FORMDATANAME);
     //$this->TPL = new TPL();
     /*if(PageController::checApi()){
     		    $this->API = new Api();
     		}*/
 }
示例#18
0
 /**
  * dil dosyası set eder
  * @return void
  */
 private function setLang()
 {
     if (Validate::_isset('lang', $_GET)) {
         $lang = Request::_get('lang');
         if (is_dir(Config::ROOT_PATH . '/language/' . $lang)) {
             Session::createSession(['language' => $lang . '.UTF-8']);
             $paramArr = array();
             foreach ($_GET as $key => $value) {
                 if ($key != 'page' && $key != 'lang') {
                     $paramArr[$key] = $value;
                 }
             }
             Header::redirect(URL::setURL($paramArr));
         }
     }
 }
示例#19
0
 /**
  * ajax connection için if bloğu oluşturur
  *
  * @return boolean
  */
 public static function ajaxTokenValidation()
 {
     return Request::_post('token') == Request::_session('token') && self::_isset('submit', $_GET) && Validate::_isset('ajax', $_POST);
 }
示例#20
0
 /**
  * HTML header içerisindeki bilgileri get eder
  * 
  * @return array
  */
 public static function getHeaderDetail()
 {
     $CURL = new Curl(Config::JSON_URL . '', ['param1' => 'HizmetLinkindenHizmetBilgisiGetir', 'link' => Request::_get('page'), 'tip' => 1], Timeout::get(1, Timeout::HOUR), true);
     return $CURL->getArray();
 }
示例#21
0
 /**
  * Does not feel right yet...
  * @param Request $request
  */
 private function redirectToLoginIfNotLoggedIn(Request $request)
 {
     $userSession = $this->serviceContainer->getUserSession();
     if ($userSession->userIsLoggedIn()) {
         return;
     }
     $actionName = $request->getGetVal('action');
     if ($actionName == 'login' || $actionName == 'performLogin') {
         return;
     }
     $loginUrl = $this->serviceContainer->getUrlBuilder()->createActionUrl('login');
     $redirectResponse = new HttpRedirectResponse($loginUrl);
     // Maybe just make a redirect method which always exits
     $this->handleResponse($redirectResponse);
     exit;
 }
示例#22
0
 /**
  * bir önceki session verilerinden bilgileri birleştirerek session'a set eder
  *
  * @return void
  */
 public function set()
 {
     if (Validate::_isset(self::FORMDATANAME, $_SESSION)) {
         $sessionArr = (array) Request::_session(self::FORMDATANAME);
         $this->dataArr['page'] = Request::_get('page');
         Session::createSession([self::FORMDATANAME => array_merge($sessionArr, $this->dataArr)]);
     } else {
         Session::createSession([self::FORMDATANAME => $this->dataArr]);
     }
     return $this;
 }
示例#23
0
<?php

use Model\App;
use Model\Request;
use Service\ConfigParams;
include __DIR__ . '/../app/bootstrap.php';
$request = Request::createFromGlobals();
$configParams = new ConfigParams(APP_PATH, APP_URL_BASE, APP_INDEX, APP_TEMPLATE_PATH, APP_TITLE, APP_VERSION, APP_DATABASE_FILE);
$app = new App($configParams);
echo $app->run($request);
示例#24
0
 /**
  * construct method
  *
  * @param array $criteria
  */
 public function __construct(array &$criteria)
 {
     $this->criteria = Request::addslashes_array($criteria);
     $this->SMARTY =& Loader::loadClass('Smarty');
 }