public function index01Action() { echo "<h3 style='color:red;font-weight:bold'>" . __METHOD__ . "</h3>"; $filter = new \Zend\I18n\Filter\Alnum(); $input = "abc !#\$&^% 123"; $output = $filter->filter($input); echo "<h2>Input: {$input}</h2><br>"; echo "<h2>Output : {$output}</h2>"; return false; }
/** * Returns a unique file name for a photo. * * @param \Photo\Model\Photo $photo the photo to get a name for * * @return string */ public function getPhotoFileName($photo) { // filtering is required to prevent invalid characters in file names. $filter = new \Zend\I18n\Filter\Alnum(true); $albumName = $filter->filter($photo->getAlbum()->getName()); // don't put spaces in file names $albumName = str_replace(' ', '-', $albumName); $extension = substr($photo->getPath(), strpos($photo->getPath(), '.')); $photoName = $albumName . '-' . $photo->getDateTime()->format('Y') . '-' . $photo->getId() . $extension; return $photoName; }
/** * * @param array $params * @param string $posts */ public function processRequest(array $params = null, $posts = null) { try { $filter = new \Zend\I18n\Filter\Alnum(); $name = $filter->filter($posts['collectionfilename']); $config = new \Zend\Config\Config(array(), true); $config->path = '/data/assets/' . $name; $config->web = '/assets/app'; $config->collections = array(); $styles = $name . 'styles'; // $config->collections = $styles; $config->collections->{$styles} = array(); $config->collections->{$styles}->debug = false; $config->collections->{$styles}->area = 'styles'; $config->collections->{$styles}->type = 'styles'; $config->collections->{$styles}->attr = array(); $config->collections->{$styles}->attr->media = 'all'; $config->collections->{$styles}->attr->rel = 'stylesheet'; $config->collections->{$styles}->assets = array(); $config->collections->{$styles}->includes = array(); $config->collections->{$styles}->includes[] = '/data/usr/share/min/css/cssmin-v3.0.1.php'; $config->collections->{$styles}->filters = array(); $config->collections->{$styles}->filters->mincss = 'Assetic\\Filter\\CssMinFilter'; $header = $name . 'header'; $config->collections->{$header} = array(); $config->collections->{$header}->debug = false; $config->collections->{$header}->area = 'head'; $config->collections->{$header}->type = 'js'; $config->collections->{$header}->attr = array(); $config->collections->{$header}->attr->type = 'text/javascript'; $config->collections->{$header}->assets = array(); $scripts = $name . 'scripts'; $config->collections->{$scripts} = array(); $config->collections->{$scripts}->debug = false; $config->collections->{$scripts}->area = 'head'; $config->collections->{$scripts}->type = 'js'; $config->collections->{$scripts}->attr = array(); $config->collections->{$scripts}->attr->type = 'text/javascript'; $config->collections->{$scripts}->assets = array(); $config->collections->{$scripts}->includes = array(); $config->collections->{$scripts}->includes[] = '/data/usr/share/min/js/JSMin.php'; $config->collections->{$scripts}->filters = array(); $config->collections->{$scripts}->filters->minjs = 'Assetic\\Filter\\JSMinFilter'; $writer = new \Zend\Config\Writer\PhpArray(); $writer->toFile(CON_ROOT_PATH . DS . 'data/assets/templates' . DS . $name . '.php', $config); return array('success' => true); } catch (\Exception $e) { return array('error' => $e->getMessage()); } }
/** * * @param array $params * @param string $posts */ public function processRequest(array $params = null, $posts = null) { try { $config = new \Zend\Config\Config(include CON_ROOT_PATH . DS . $this->getEntity()->getCurrentPath() . DS . $posts['ident'] . '.php', true); $filter = new \Zend\I18n\Filter\Alnum(); $name = $filter->filter($posts['collectionname']); $save = false; switch ($posts['collectiontype']) { case 'styles': $save = true; $styles = $name . 'styles'; $config->collections->{$styles} = array(); $config->collections->{$styles}->debug = false; $config->collections->{$styles}->area = 'styles'; $config->collections->{$styles}->type = 'styles'; $config->collections->{$styles}->attr = array(); $config->collections->{$styles}->attr->media = 'all'; $config->collections->{$styles}->attr->rel = 'stylesheet'; $config->collections->{$styles}->assets = array(); $config->collections->{$styles}->includes = array(); $config->collections->{$styles}->includes[] = '/data/usr/share/min/css/cssmin-v3.0.1.php'; $config->collections->{$styles}->filters = array(); $config->collections->{$styles}->filters->mincss = 'Assetic\\Filter\\CssMinFilter'; break; case 'scripts': $save = true; $scripts = $name . 'scripts'; $config->collections->{$scripts} = array(); $config->collections->{$scripts}->debug = false; $config->collections->{$scripts}->area = 'head'; $config->collections->{$scripts}->type = 'js'; $config->collections->{$scripts}->attr = array(); $config->collections->{$scripts}->attr->type = 'text/javascript'; $config->collections->{$scripts}->assets = array(); $config->collections->{$scripts}->includes = array(); $config->collections->{$scripts}->includes[] = '/data/usr/share/min/js/JSMin.php'; $config->collections->{$scripts}->filters = array(); $config->collections->{$scripts}->filters->minjs = 'Assetic\\Filter\\JSMinFilter'; break; case 'header': $save = true; $header = $name . 'header'; $config->collections->{$header} = array(); $config->collections->{$header}->debug = false; $config->collections->{$header}->area = 'head'; $config->collections->{$header}->type = 'js'; $config->collections->{$header}->attr = array(); $config->collections->{$header}->attr->type = 'text/javascript'; $config->collections->{$header}->assets = array(); break; default: break; } if (true === $save) { $writer = new \Zend\Config\Writer\PhpArray(); $writer->toFile(CON_ROOT_PATH . DS . $this->getEntity()->getCurrentPath() . DS . $posts['ident'] . '.php', $config); return array('success' => true); } else { return array('warn' => 'wrong_parameter'); } } catch (\Exception $e) { return array('error' => $e->getMessage()); } }
<?php /** * Copyright (c) 2014 Keith Casey. * * This code is designed to accompany the lynda.com video course "Design Patterns in PHP" * by Keith Casey. If you've received this code without seeing the videos, go watch the * videos. It will make way more sense and be more useful in general. */ require 'vendor/autoload.php'; $input = "This is a string of text that should be filtered & handle 's properly."; $htmlEntities = new Zend\Filter\HtmlEntities(); echo $htmlEntities->filter($input); echo '<br />'; $alphanumeric = new \Zend\I18n\Filter\Alnum(); echo $alphanumeric->filter($input); echo '<br />'; // Now allow whitespace $alphanumeric = new \Zend\I18n\Filter\Alnum(true); echo $alphanumeric->filter($input);
public function jsonmapasaAction() { $distrit = $this->params()->fromQuery('distrito'); $view = new viewModel(); $view->setTerminal(true); $valor1 = explode(',', $distrit); $distrito = $valor1[0]; $texto = $this->params()->fromQuery('q'); setcookie('distrito', $distrito); $valor = explode(" ", $texto); if ($valor[0] == 'restaurante:') { $buscar = $valor[1] . ' ' . $valor[2] . ' ' . $valor[3] . ' ' . $valor[4]; $plato = $valor[0] . '"' . $buscar . '"'; } elseif ($valor[0] == 'tag:') { $buscar = $valor[1] . ' ' . $valor[2] . ' ' . $valor[3]; $plato = $valor[0] . '"' . $buscar . '"'; } elseif ($valor[0] == 'name:') { $buscar = $valor[1] . ' ' . $valor[2] . ' ' . $valor[3] . ' ' . $valor[4]; $plato = $valor[0] . '"' . $buscar . '"'; } else { $filter = new \Zend\I18n\Filter\Alnum(true); $plato = $filter->filter($texto); setcookie('q', $texto); } if ($distrito and $distrito != 'LIMA') { $distrit = '"' . $distrito . '"'; $resultados = false; $palabraBuscar = isset($plato) ? $plato : false; $list = 1000; $fd = array('fq' => 'en_estado:activo AND restaurant_estado:activo AND distrito:' . strtoupper($distrito), 'fl' => 'id,latitud,longitud,tx_descripcion,va_imagen,restaurante_estado,restaurante,name,plato_tipo,distrito', 'wt' => 'json'); if ($palabraBuscar) { $solar = \Classes\Solr::getInstance()->getSolr(); if (get_magic_quotes_gpc() == 1) { $palabraBuscar = stripslashes($palabraBuscar); } try { $resultados = $solar->search($palabraBuscar, 0, $list, $fd); } catch (Exception $e) { die("<html><head><title>SEARCH EXCEPTION</title><body><pre>{$e->__toString()}</pre></body></html>"); } } } elseif ($distrito == 'LIMA') { $limite = 1000; $resultados = false; $palabraBuscar = isset($plato) ? $plato : false; $fd = array('fq' => 'en_estado:activo AND restaurant_estado:activo AND departamento:' . strtoupper($distrito), 'fl' => 'id,latitud,longitud,tx_descripcion,va_imagen,restaurante_estado,restaurante,name,plato_tipo,distrito', 'wt' => 'json'); if ($palabraBuscar) { $solar = \Classes\Solr::getInstance()->getSolr(); if (get_magic_quotes_gpc() == 1) { $palabraBuscar = stripslashes($palabraBuscar); } try { $resultados = $solar->search($palabraBuscar, 0, $limite, $fd); // var_dump($resultados);exit; } catch (Exception $e) { $this->redirect()->toUrl('/'); } } } else { $limite = 1000; // $distrito= '"LIMA"'; $resultados = false; $palabraBuscar = isset($plato) ? $plato : false; $fd = array('fq' => 'en_estado:activo AND restaurant_estado:activo ', 'fl' => 'id,latitud,longitud,tx_descripcion,va_imagen,restaurante_estado,restaurante,name,plato_tipo,distrito', 'wt' => 'json'); if ($palabraBuscar) { $solar = \Classes\Solr::getInstance()->getSolr(); if (get_magic_quotes_gpc() == 1) { $palabraBuscar = stripslashes($palabraBuscar); } try { $resultados = $solar->search($palabraBuscar, 0, $limite, $fd); // var_dump($resultados);exit; } catch (Exception $e) { $this->redirect()->toUrl('/'); } } } echo $resultados->getRawResponse(); exit; }
$filterSQLReservedWordsData = $filterLowerCase->filter($filterSQLReservedWordsData); $filterSQLReservedWordsData1 = $filterSQLReservedWords->filter($filterSQLReservedWordsData); //print_r('xxxxxx'.$filterSQLReservedWordsData.'----'); // print_r($filterSQLReservedWordsData1.'xxxx'); // print_r( strlen($filterSQLReservedWordsData). 'dddd' . strlen ($filterSQLReservedWordsData1) ) ; if (strlen($filterSQLReservedWordsData) != strlen($filterSQLReservedWordsData1)) { print_r('xxxxxx' . $filterSQLReservedWordsData . '----'); $errorcode = 999; } $messageName = 'Role Adı '; $controlMessage = $messageName; // echo $filterAlpha->filter($vName); //echo $filterAlpha->filter("This....!!!As is (my) content: 123"); // if ( strlen($filterAlpha->filter($vName)) != strlen($vName) ) { if (!$validatorAlpha->isValid($vName)) { $vName = $filterAlpha->filter($vName); $controlMessage = $controlMessage . ' içerisinde alfabetik olmayan değer var!!! // '; $errorcode = 3; $hatasayisi = $hatasayisi + 1; } if (!$validatorNotEmptyString->isValid($vName)) { $result = $validatorNotEmptyString->isValid($vName); $controlMessage = $controlMessage . ' Boş Değer //'; $errorcode = 2; $hatasayisi = $hatasayisi + 1; } $validatorStringLength->setMessages(array('stringLengthTooShort' => $messageName . 'en az ' . $validatorStringLength->getMin() . ' karakter olmak zorunda...', 'stringLengthTooLong' => $messageName . 'en fazla ' . $validatorStringLength->getMax() . ' karakter olmak zorunda...')); if (!$validatorStringLength->isValid($vName)) { $messages = $validatorStringLength->getMessages(); $controlMessage = $controlMessage . current($messages); $errorcode = 1;
public function index2Action() { $filter = new \Zend\I18n\Filter\Alnum(); echo $filter->filter("This is (my) content: 123"); return false; }