/**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\StripTags())->attach(new \Zend\Filter\StringTrim())->attach(new \Zend\Filter\HtmlEntities())->attach(new \Zend\Filter\StripNewlines())->attach(new \Zend\Filter\StringToLower(array('encoding' => 'UTF-8')))->attach(new \Zend\Filter\PregReplace(array('pattern' => array("/javascript/i", "/([^A-Za-z0-9])*(document)([^A-Za-z0-9])+/i", "/([^A-Za-z0-9])*(onload)([^A-Za-z0-9])+/i", "/([^A-Za-z0-9])*(iframe)([^A-Za-z0-9])+/i", "/([^A-Za-z0-9])*(object)([^A-Za-z0-9])+/i", "/(SRC=)|(src =)|(src%3d)/i", "/(SRC=)|(src =)|(src%3d)/i", "/(href=)|(href =)|(href%3d)|(href)/i", "/script/i", "/SRC=/i", "/<EMBED/i", "/(#)|(%23)/", "/(\\{)|(%7b)/", "/(=)|(%3d)/", "/(!--)|(&#33;&#95;&#95;)/", "/(<)[^A-Za-z0-9]*(img)/i", "/fromCharCode/i", "/alert/i", "/.js/i", "/onreadystatechange/i", "/xmlhttprequest/i", "/([^A-Za-z0-9](eval))|((eval)[^A-Za-z0-9]+)/i"), 'replacement' => 'john'), 200));
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\PregReplace(array('pattern' => array("/([^A-Za-z0-9])*(iframe)([^A-Za-z0-9])+/i", "/(SRC=)|(src =)|(src%3d)/i", "/(SRC=)|(src =)|(src%3d)/i", "/(href=)|(href =)|(href%3d)|(href)/i", "/SRC=/i", "/<EMBED/i", "/(#)|(%23)/", "/(\\{)|(%7b)/", "/(!--)|(&#33;&#95;&#95;)/", "/(<)[^A-Za-z0-9]*(img)/i", "/([^A-Za-z0-9](eval))|((eval)[^A-Za-z0-9]+)/i"), 'replacement' => ''), 200));
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\PregReplace(array('pattern' => array('/<!\\[cdata\\[(.*?)\\]\\]>/is'), 'replacement' => ''), 200));
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\PregReplace(array('pattern' => array("/(\\\\)|(%5c)/", "/(<)|(%3c)/", "/(>)|(%3e)/", "/(\\/)|(%2f)/", "/(\\()|(&#40;)/", "/(\\))|(&#41;)/", "/&quot/", "/(&)|(%26)/"), 'replacement' => ''), 200));
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\StringToLower(array('encoding' => 'UTF-8')));
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\PregReplace(array('pattern' => array("/(;)|(%3b)/", "/\\/\\*/", "/\\*\\//", "/\\*/", "/@@/", "/([^A-Za-z0-9])(@)([^A-Za-z0-9])*/", "/nchar/", "/NCHAR/", "/nvarchar/", "/NVARCHAR/", "/varchar/", "/VARCHAR/", "/char/", "/CHAR/", "/(alter)(\\s)*/", "/(ALTER)(\\s)*/", "/(\\s)+(begin)(\\s)+/", "/(\\s)+(BEGIN)(\\s)+/", "/(\\s)+(cast)(\\s)+/", "/(\\s)+(CAST)(\\s)+/", "/(\\s)+(create)(\\s)+/", "/(\\s)+(CREATE)(\\s)+/", "/(\\s)+(cursor)(\\s)+/", "/(\\s)+(CURSOR)(\\s)+/", "/(\\s)+(declare)(\\s)*/", "/(\\s)+(DECLARE)(\\s)*/", "/([^A-Za-z0-9])(delete)([^A-Za-z0-9])*/", "/([^A-Za-z0-9])(DELETE)([^A-Za-z0-9])*/", "/([^A-Za-z0-9])(drop)([^A-Za-z0-9])*/", "/([^A-Za-z0-9])(DROP)([^A-Za-z0-9])*/", "/(\\s)+(end)(\\s)+/", "/(\\s)+(END)(\\s)+/", "/(\\s)+(execute)(\\s)+/", "/(\\s)+(EXECUTE)(\\s)+/", "/(\\s)+(exec)(\\s)+/", "/(\\s)+(EXEC)(\\s)+/", "/fetch/", "/FETCH/", "/insert/", "/INSERT/", "/(\\s)+(kill)(\\s)+/", "/(\\s)+(KILL)(\\s)+/", "/(\\s)+(open)(\\s)+/", "/(\\s)+(OPEN)(\\s)+/", "/select/", "/SELECT/", "/sysobjects/", "/SYSOBJECTS/", "/syscolumns/", "/SYSCOLUMNS/", "/(\\s)+(sys)(\\s)+/", "/(\\s)+(SYS)(\\s)+/", "/table/", "/TABLE/", "/([^A-Za-z0-9])(update)([^A-Za-z0-9])+/", "/([^A-Za-z0-9])(UPDATE)([^A-Za-z0-9])+/", "/([^A-Za-z0-9])(or)([^A-Za-z0-9])+/", "/([^A-Za-z0-9])(OR)([^A-Za-z0-9])+/", "/([^A-Za-z0-9])(UNION)([^A-Za-z0-9])+/", "/([^A-Za-z0-9])(union)([^A-Za-z0-9])+/"), 'replacement' => '/*$0*/')));
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\PregReplace(array('pattern' => array("/javascript/i", "/([^A-Za-z0-9])*(document)([^A-Za-z0-9])+/i", "/([^A-Za-z0-9])*(onload)([^A-Za-z0-9])+/i", "/([^A-Za-z0-9])*(object)([^A-Za-z0-9])+/i", "/script/i", "/<EMBED/i", "/(#)|(%23)/", "/(\\{)|(%7b)/", "/(!--)|(&#33;&#95;&#95;)/", "/fromCharCode/i", "/alert/i", "/.js/i", "/onreadystatechange/i", "/xmlhttprequest/i", "/([^A-Za-z0-9](eval))|((eval)[^A-Za-z0-9]+)/i"), 'replacement' => ''), 200));
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\StringTrim());
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\HtmlEntities(array('quotestyle' => ENT_QUOTES, 'charset' => 'UTF-8', 'encoding' => 'UTF-8')))->attach(new \Zend\Filter\StripTags())->attach(new \Zend\Filter\StringTrim())->attach(new \Zend\Filter\StripNewlines());
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\PregReplace(array('pattern' => array("/@@/", "/nchar/i", "/nvarchar/i", "/varchar/i", "/char/i", "/(alter)(\\s)*/i", "/(\\s)+(begin)(\\s)+/", "/(\\s)+(cast)(\\s)+/", "/(\\s)+(create)(\\s)+/i", "/(\\s)+(cursor)(\\s)+/i", "/(\\s)+(declare)(\\s)*/i", "/([^A-Za-z0-9_])(delete)([^A-Za-z0-9])*/i", "/([^A-Za-z0-9])(drop)([^A-Za-z0-9])*/i", "/(\\s)+(end)(\\s)+/i", "/(\\s)+(execute)(\\s)+/", "/(\\s)+(EXECUTE)(\\s)+/", "/(\\s)+(exec)(\\s)+/i", "/fetch/i", "/insert/i", "/(\\s)+(kill)(\\s)+/i", "/(\\s)+(open)(\\s)+/i", "/select/i", "/sysobjects/i", "/syscolumns/i", "/(\\s)+(sys)(\\s)+/i", "/table/i", "/([^A-Za-z0-9_])(update)([^A-Za-z0-9])+/i", "/([^A-Za-z0-9])(or)([^A-Za-z0-9])+/i", "/([^A-Za-z0-9])(union)([^A-Za-z0-9])+/i"), 'replacement' => '/*$0*/')));
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\PregReplace(array('pattern' => array("/&#x27;/i", "/&#x2F;/i", "/&#42;/i", "/&#44;/i", "/&#45;/i", "/&#59;/i", "/&#61;/i", "/&#64;/i", "/&#91;/i", "/&#92;/i", "/&#93;/i", "/&#94;/i", "/&#95;/i", "/&#96;/i", "/&#123;/i", "/&#125;/i", "/&#124;/i", "/&#126;/i"), 'replacement' => '')));
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\PregReplace(array('pattern' => array("/&amp;/i", "/&lt;/i", "/&gt;/i", "/&quot;/i", "/&#x27;/i", "/&#x2F;/i", "/&#42;/i", "/&#44;/i", "/&#45;/i", "/&#59;/i", "/&#61;/i", "/&#64;/i", "/&#91;/i", "/&#92;/i", "/&#93;/i", "/&#94;/i", "/&#95;/i", "/&#96;/i", "/&#123;/i", "/&#125;/i", "/&#124;/i", "/&#126;/i", "/([#|&#35;|%|&#37;|&|&#38;|&amp;]+([A-Fa-f0-9]){2,3})/i"), 'replacement' => '')));
     return $filterChain;
 }
 /**
  * service ceration via factory on zend service manager
  * @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
  * @return boolean|\PDO
  */
 public function createService(\Zend\ServiceManager\ServiceLocatorInterface $serviceLocator)
 {
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\Whitelist(array('list' => array('false'))));
     return $filterChain;
 }
Example #14
0
 /**
  * getMetadata() is required by the Manifest Interface.
  *
  * These are the following metadatas that will be setup:
  *
  * normalizedActionName
  *   - metadata for actions
  *   - value will be a dashed name for the action named in 'actionName'
  * normalizedProviderName
  *   - metadata for providers
  *   - value will be a dashed-name for the provider named in 'providerName'
  * normalizedProviderSpecialtyNames
  *   - metadata for providers
  * normalizedActionableMethodLongParameters
  *   - metadata for providers
  * normalizedActionableMethodShortParameters
  *   - metadata for providers
  *
  * @return array Array of Metadatas
  */
 public function getMetadata()
 {
     $metadatas = array();
     // setup the camelCase to dashed filter to use since cli expects dashed named
     $lowerFilter = new \Zend\Filter\FilterChain();
     $lowerFilter->attach(new \Zend\Filter\StringToLower());
     // get the registry to get the action and provider repository
     $actionRepository = $this->_registry->getActionRepository();
     $providerRepository = $this->_registry->getProviderRepository();
     // loop through all actions and create a metadata for each
     foreach ($actionRepository->getActions() as $action) {
         // each action metadata will be called
         $metadatas[] = new Metadata\Tool(array('name' => 'normalizedActionName', 'value' => $lowerFilter->filter($action->getName()), 'reference' => $action, 'actionName' => $action->getName(), 'clientName' => 'all'));
     }
     foreach ($providerRepository->getProviderSignatures() as $providerSignature) {
         // create the metadata for the provider's cliProviderName
         $metadatas[] = new Metadata\Tool(array('name' => 'normalizedProviderName', 'value' => $lowerFilter->filter($providerSignature->getName()), 'reference' => $providerSignature, 'clientName' => 'all', 'providerName' => $providerSignature->getName()));
         // create the metadatas for the per provider specialites in providerSpecaltyNames
         foreach ($providerSignature->getSpecialties() as $specialty) {
             if ($specialty == '_Global') {
                 continue;
             }
             $metadatas[] = new Metadata\Tool(array('name' => 'normalizedSpecialtyName', 'value' => $lowerFilter->filter($specialty), 'reference' => $providerSignature, 'clientName' => 'all', 'providerName' => $providerSignature->getName(), 'specialtyName' => $specialty));
         }
         // $actionableMethod is keyed by the methodName (but not used)
         foreach ($providerSignature->getActionableMethods() as $actionableMethodData) {
             $methodLongParams = array();
             $methodShortParams = array();
             // $actionableMethodData get both the long and short names
             foreach ($actionableMethodData['parameterInfo'] as $parameterInfoData) {
                 // filter to dashed
                 $methodLongParams[$parameterInfoData['name']] = $lowerFilter->filter($parameterInfoData['name']);
                 // simply lower the character, (its only 1 char after all)
                 $methodShortParams[$parameterInfoData['name']] = strtolower($parameterInfoData['name'][0]);
             }
             // create metadata for the long name cliActionableMethodLongParameters
             $metadatas[] = new Metadata\Tool(array('name' => 'normalizedActionableMethodLongParams', 'value' => $methodLongParams, 'clientName' => 'console', 'providerName' => $providerSignature->getName(), 'specialtyName' => $actionableMethodData['specialty'], 'actionName' => $actionableMethodData['actionName'], 'reference' => &$actionableMethodData));
             // create metadata for the short name cliActionableMethodShortParameters
             $metadatas[] = new Metadata\Tool(array('name' => 'normalizedActionableMethodShortParams', 'value' => $methodShortParams, 'clientName' => 'console', 'providerName' => $providerSignature->getName(), 'specialtyName' => $actionableMethodData['specialty'], 'actionName' => $actionableMethodData['actionName'], 'reference' => &$actionableMethodData));
         }
     }
     return $metadatas;
 }
Example #15
0
 public function index29Action()
 {
     $input = '   zend_framework_is_not_difficult  ';
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attachByName('StringToUpper')->attachByName('StringTrim')->attachByName('Word\\UnderscoreToDash');
     $output = $filterChain->filter($input);
     echo "<h3>" . $input . "</h3>";
     echo "<h3>" . $output . "</h3>";
     return false;
 }
Example #16
0
File: Console.php Project: hjr3/zf2
 /**
  * convertToClientNaming()
  *
  * Convert words to client specific naming, in this case is lower, dash separated
  *
  * Filters are lazy-loaded.
  *
  * @param string $string
  * @return string
  */
 public function convertToClientNaming($string)
 {
     if (!$this->_filterToClientNaming) {
         $filter = new \Zend\Filter\FilterChain();
         $filter->attach(new \Zend\Filter\Word\CamelCaseToDash());
         $filter->attach(new \Zend\Filter\StringToLower());
         $this->_filterToClientNaming = $filter;
     }
     return $this->_filterToClientNaming->filter($string);
 }
Example #17
0
 protected function _convertActionNameToFilesystemName($actionName)
 {
     $filter = new \Zend\Filter\FilterChain();
     $filter->addFilter(new \Zend\Filter\Word\CamelCaseToDash())->addFilter(new \Zend\Filter\StringToLower());
     return $filter->filter($actionName);
 }
Example #18
0
 /**
  * Prepare the attribute form
  *
  * @param $attributes array           
  * @return \ProductAdmin\Form\ProductForm
  */
 public function createAttributesElements(array $attributes)
 {
     $customHydrator = new ClassMethods(true);
     $parentFilter = new \Zend\InputFilter\InputFilter();
     $fieldset = new \Zend\Form\Fieldset('attributes');
     //         $fieldset->setUseAsBaseFieldset(true);
     $fieldset->setObject(new \Zend\Stdlib\ArrayObject());
     $fieldset->setFormFactory($this->getFormFactory());
     // thanks to jurians #zftalk irc
     $fieldInput = null;
     $inputFilter = new \Zend\InputFilter\InputFilter();
     foreach ($attributes as $attribute) {
         $formitem = array();
         $filterChain = new \Zend\Filter\FilterChain();
         $name = $attribute->getName();
         $label = $attribute->getLabel() ? $attribute->getLabel() : "-";
         $type = $attribute->getType() ? $attribute->getType() : "string";
         $isRequired = $attribute->getIsRequired();
         $sourceModel = $attribute->getSourceModel();
         $filters = $attribute->getFilters();
         $validators = $attribute->getValidators();
         $cssStyles = $attribute->getCss();
         $validators = !empty($validators) ? json_decode($validators, true) : array();
         // create the new form element array structure
         $formitem['attributes'] = $attribute->getCustomAttributes() ? json_decode($attribute->getCustomAttributes(), true) : json_decode($attribute->attributes, true);
         $formitem['attributes']['id'] = $name;
         $formitem['attributes']['class'] = !empty($attribute->basecss) ? $attribute->basecss : null;
         $formitem['attributes']['name'] = $name;
         $formitem['type'] = !empty($sourceModel) ? $sourceModel : $attribute->input_type;
         $formitem['options']['label'] = $label;
         if ($attribute->getData()) {
             $formitem['options']['value_options'] = json_decode($attribute->getData(), true);
         }
         $filterChain->attachByName('null');
         // set as default
         // set the css style of the element
         if (!empty($cssStyles)) {
             $formitem['attributes']['class'] .= " " . $cssStyles;
         }
         // Handle the dates
         if (!empty($type) && $type == "date") {
             $customHydrator->addStrategy($name, new DateTimeStrategy());
             $typeSource = 'Zend\\Form\\Element\\Date';
             $formitem['type'] = "\\Zend\\Form\\Element\\Date";
             $formitem['options']['format'] = 'd/m/Y';
         }
         // handle the validators preferences of the attribute
         foreach ($validators as $validator) {
             $formitem['validators'] = $validator;
         }
         // var_dump($type);
         // var_dump($customHydrator);
         //             var_dump($formitem);
         // Attach the form item into the form
         $fieldset->add($formitem);
         $fieldInput = new \Zend\InputFilter\Input($name);
         $fieldInput->setRequired($isRequired);
         // handle the filters preferences of the attribute
         if (!empty($filters)) {
             // get the filters attached to the attribute
             $filters = json_decode($filters, true);
             foreach ($filters as $filter) {
                 // if the filter is an array check it by name
                 if (is_array($filter)) {
                     // If the filter is a ...
                     if ($filter['name'] == "File\\RenameUpload") {
                         // create the filter Zend\InputFilter\FileInput
                         $thefilter = new \Zend\InputFilter\FileInput($filter['options']);
                         // ... but how to attach the new filter to the
                         // chain?
                         $chain = new \Zend\Filter\FilterChain();
                         // ... in this way it doesn't work!!
                         $chain->attachByName("filerenameupload", $filter['options']);
                         $filterChain->merge($chain);
                         // just for debugging it ...
                         $filtersApplied = $filterChain->getFilters();
                         //                             var_dump($filtersApplied->toArray());
                     }
                 } elseif ($filter == "cleanurl") {
                     // custom filter
                     $filterChain->attach(new \ProductAdmin\Form\Filter\Cleanurl());
                 } elseif (is_string($filter)) {
                     $filterChain->attachByName($filter);
                 }
             }
         }
         $fieldInput->setFilterChain($filterChain);
         $inputFilter->add($fieldInput);
     }
     $fieldset->setHydrator($customHydrator);
     $this->add($fieldset);
     $parentFilter->add($inputFilter, 'attributes');
     // thanks to GeeH #zftalk irc
     $this->setInputFilter($parentFilter);
     return $this;
 }
 protected function _getStandardFilter()
 {
     $baseInputFilterChain = new \Zend\Filter\FilterChain();
     $baseInputFilterChain->attach(new HtmlEntities())->attach(new StringTrim())->attach(new StripNewlines())->attach(new StripTags());
     return $baseInputFilterChain;
 }
Example #20
0
 public function onBootstrap(EventInterface $e)
 {
     $serviceManager = $e->getApplication()->getServiceManager();
     $config = $e->getApplication()->getServiceManager()->get('config');
     $translator = $serviceManager->get('translator');
     // Gestion de la locale
     if (PHP_SAPI !== 'cli') {
         //translator
         // Gestion locale pour le back
         if ($serviceManager->get('router')->match($serviceManager->get('request')) && strpos($serviceManager->get('router')->match($serviceManager->get('request'))->getMatchedRouteName(), 'admin') !== false) {
             if ($e->getRequest()->getCookie() && $e->getRequest()->getCookie()->offsetExists('pg_locale_back')) {
                 $locale = $e->getRequest()->getCookie()->offsetGet('pg_locale_back');
             }
         }
         if (empty($locale)) {
             if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
                 $locale = \Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']);
             } else {
                 $locale = 'fr_FR';
             }
         }
         $translator->setLocale($locale);
         // plugins
         $translate = $serviceManager->get('viewhelpermanager')->get('translate');
         $translate->getTranslator()->setLocale($locale);
         $options = $serviceManager->get('playgroundcore_module_options');
         $options->setLocale($locale);
     }
     // positionnement de la langue pour les traductions de date avec strftime
     setlocale(LC_TIME, "fr_FR", 'fr_FR.utf8', 'fra');
     AbstractValidator::setDefaultTranslator($translator, 'playgroundcore');
     /*
      * Entity translation based on Doctrine Gedmo library
      */
     $doctrine = $serviceManager->get('doctrine.entitymanager.orm_default');
     $evm = $doctrine->getEventManager();
     $translatableListener = new \Gedmo\Translatable\TranslatableListener();
     // TODO : Set the Default locale to be taken from config
     $translatableListener->setDefaultLocale('fr_FR');
     // If no translation is found, fallback to entity data
     $translatableListener->setTranslationFallback(true);
     // set Locale
     if (!empty($locale)) {
         $translatableListener->setTranslatableLocale($locale);
     }
     $evm->addEventSubscriber($translatableListener);
     /**
      * Adding a Filter to slugify a string (make it URL compliiant)
      */
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->getPluginManager()->setInvokableClass('slugify', 'PlaygroundCore\\Filter\\Slugify');
     $filterChain->attach(new Filter\Slugify());
     // Start the session container
     $sessionConfig = new SessionConfig();
     $sessionConfig->setOptions($config['session']);
     $sessionManager = new SessionManager($sessionConfig);
     $sessionManager->start();
     /**
      * Optional: If you later want to use namespaces, you can already store the
      * Manager in the shared (static) Container (=namespace) field
      */
     \Zend\Session\Container::setDefaultManager($sessionManager);
     // Google Analytics : When the render event is triggered, we invoke the view helper to
     // render the javascript code.
     $e->getApplication()->getEventManager()->attach(\Zend\Mvc\MvcEvent::EVENT_RENDER, function (\Zend\Mvc\MvcEvent $e) use($serviceManager) {
         $view = $serviceManager->get('ViewHelperManager');
         $plugin = $view->get('googleAnalytics');
         $plugin();
         $pluginOG = $view->get('facebookOpengraph');
         $pluginOG();
     });
     if (PHP_SAPI !== 'cli') {
         $session = new Container('facebook');
         $fb = $e->getRequest()->getPost()->get('signed_request');
         if ($fb) {
             list($encoded_sig, $payload) = explode('.', $fb, 2);
             $sig = base64_decode(strtr($encoded_sig, '-_', '+/'));
             $data = json_decode(base64_decode(strtr($payload, '-_', '+/')), true);
             $session->offsetSet('signed_request', $data);
             // This fix exists only for safari on Windows : we need to redirect the user to the page outside of iframe
             // for the cookie to be accepted. Core just adds a 'redir_fb_page_id' var to alert controllers
             // that they need to send the user back to FB...
             if (!count($_COOKIE) > 0 && strpos($_SERVER['HTTP_USER_AGENT'], 'Safari')) {
                 echo '<script type="text/javascript">' . 'window.top.location.href = window.location.href+"?redir_fb_page_id=' . $data["page"]["id"] . '";' . '</script>';
             }
             // This fix exists only for IE6+, when this app is embedded into an iFrame : The P3P policy has to be set.
             $response = $e->getResponse();
             if ($response instanceof \Zend\Http\Response && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') || strpos($_SERVER['HTTP_USER_AGENT'], 'rv:11.'))) {
                 $response->getHeaders()->addHeaderLine('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
             }
         }
     }
 }
 protected function _convertControllerNameToFilesystemName($controllerName)
 {
     $filter = new \Zend\Filter\FilterChain();
     $filter->attach(new \Zend\Filter\Word\CamelCaseToDash())->attach(new \Zend\Filter\StringToLower());
     return $filter->filter($controllerName);
 }
 /**
  * Call
  */
 public function call()
 {
     //print_r('MiddlewareTest middleware call method------');
     //print_r($this->next);
     //Read flash messaging from previous request if available
     //$this->loadMessages();
     //Prepare flash messaging for current request
     //$env = $this->app->environment();
     //$env['slim.flash'] = $this;
     // Create a filter chain and filter for usage
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\StripTags())->attach(new \Zend\Filter\StringTrim())->attach(new \Zend\Filter\HtmlEntities())->attach(new \Zend\Filter\StripNewlines())->attach(new \Zend\Filter\StringToLower());
     echo $filterChain->filter("deneme   <a  TEST href='test'>");
     // Create a validator chain and add validators to it
     $validatorChain = new \Zend\Validator\ValidatorChain();
     $validatorChain->attach(new \Zend\Validator\StringLength(array('min' => 6, 'max' => 12)))->attach(new \Zend\I18n\Validator\Alnum());
     // Validate the username
     if ($validatorChain->isValid("testteeewwwwwwwwwwwww__")) {
         // username passed validation
     } else {
         // username failed validation; print reasons
         /* foreach ($validatorChain->getMessages() as $message) {
                echo "$message\n";
            }*/
         //$this->app->redirect('/error');
         //$this->app->error();
         //$this->app->halt(500, "info status test!!!!");
         /*$this->app->contentType('application/json');
           $this->app->halt(500, '{"error":"Something went wrong"}');
           $this->app->stop();*/
         //exit();
         //$this->app->run();
         /*$response = $this->app->response();
         
                     //Generate Response headers
                     $response->header('Content-Type', "application/json");
                     $response->status(DEFAULT_RESPONSE_CODE);                  
                     $response->header('Content-Length', '500');
         
                     $responseBody = array('message'=> $message);
                     $response->body(json_encode($responseBody));
         
         
                     $response->send();*/
         //ob_clean();
         $publicHash = '3441df0babc2a2dda551d7cd39fb235bc4e09cd1e4556bf261bb49188f548348';
         $privateHash = 'e249c439ed7697df2a4b045d97d4b9b7e1854c3ff8dd668c779013653913572e';
         $content = json_encode(array('test' => 'content'));
         //$this->app->setPublicHash('3441df0babc2a2dda551d7cd39fb235bc4e09cd1e4556bf261bb49188f548348');
         //
         //print_r("------public hash---------".$this->app->getPublicHash()."------public hash---------");
         /*$hash = hash_hmac('sha256', $content, $privateHash);
         
                     $headers = array(
                         'X-Public: '.$publicHash,
                         'X-Hash: '.$hash
                     );
                     //ob_flush();
                     
                     
                     $ch = curl_init('http://localhost/slim_redirect_test/index.php/redirected_path');
                     curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
                     curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
                     curl_setopt($ch,CURLOPT_POSTFIELDS,$content);
         
                     $result = curl_exec($ch);
                     curl_close($ch);*/
         //ob_end_flush();
         /*ob_end_clean();
           $newURL = 'http://localhost/slim_redirect_test/index.php/redirected_path';
           header("Location: {$newURL}");*/
     }
     $validator = new \Zend\Validator\Barcode('EAN13');
     $floatValidator = new \Zend\I18n\Validator\IsFloat();
     if ($floatValidator->isValid(5.3)) {
         //print_r ("--float test edildi onaylandı---");
         $intValidator = new \Zend\I18n\Validator\IsInt();
     }
     $intValidator->setMessage("test validation");
     if ($intValidator->isValid(5)) {
         //print_r ("--int test edildi onaylandı---");
         $validator = new \Zend\Validator\StringLength();
     }
     $validator->setMax(6);
     $validator->isValid("Test");
     // returns true
     $validator->isValid("Testing");
     // returns false
     /*print_r($validator->isValid("Test"));
       print_r("fffffffffffffffffffff----    ");
       print_r($validator->isValid("Testing"));*/
     if (!$validator->isValid("Testing")) {
         //print_r("---is not valid----");
         $logger = new \Zend\Log\Logger();
     }
     $writer = new \Zend\Log\Writer\Stream('php://output');
     /*$logger->addWriter($writer);
       $logger->log(\Zend\Log\Logger::INFO, 'Informational message');
       $this->app->log->debug("test loggg");*/
     $this->next->call();
     //$this->save();
 }
Example #23
0
 /**
  * 設定關鍵字
  * @param $data
  * @param $pageRes
  */
 public function setTags($data, $pageRes)
 {
     $em = $this->getEntityManager();
     foreach ($pageRes->getPageTags() as $tag) {
         $em->remove($tag);
     }
     $em->flush();
     $filterChain = new \Zend\Filter\FilterChain();
     $filterChain->attach(new \Zend\Filter\StringTrim())->attach(new \Zend\Filter\StripTags());
     foreach (explode(",", $data['tags']) as $val) {
         $val = $filterChain->filter($val);
         if (!$val) {
             continue;
         }
         $tagRes = $em->getRepository('Base\\Entity\\PageTag')->findOneBy(array('tag_name' => $val));
         if (!$tagRes) {
             $tagRes = new \Base\Entity\PageTag();
             $tagRes->setTagName($val);
             $em->persist($tagRes);
             $em->flush();
         }
         $tagRes->addPage($pageRes);
         $em->persist($tagRes);
     }
     $em->flush();
 }
Example #24
0
    return new \Zend\Db\TableGateway\TableGateway('purchase', $dbAdapter, null, $resultSetPrototype);
}, 'DocumentTracker' => function () {
    //Returns the document tracker
    return new Application\Model\DocumentTracker($_COOKIE);
}, 'EmailValidator' => function () {
    //Returns an email address validator.
    $oValidator = new Zend\Validator\EmailAddress();
    return $oValidator;
}, 'EmailFilter' => function () {
    //Setup a filter for email address values.
    $oFilterChain = new Zend\Filter\FilterChain();
    $oFilterChain->attach(new \Zend\Filter\StripTags());
    $oFilterChain->attach(new Zend\Filter\StringTrim());
    return $oFilterChain;
}, 'IdentFilter' => function () {
    $oFilterChain = new Zend\Filter\FilterChain();
    $oFilterChain->attach(new \Zend\Filter\StripTags());
    $oFilterChain->attach(new \Zend\Filter\ToInt());
    return $oFilterChain;
}, 'AppLog' => function () {
    //Setup the application logger
    $log = new Zend\Log\Logger();
    $writer = new Zend\Log\Writer\Stream(__DIR__ . '/../../../data/log/application.log');
    $log->addWriter($writer);
    return $log;
}, 'SessionManager' => function ($sm) {
    $config = $sm->get('config');
    //REading session settings in config/autoload/global.php
    if (isset($config['session'])) {
        $session = $config['session'];
        $sessionConfig = null;