-
WIBUHAX0R1337
-
/
home
/
cideo
/
library
/
My
/
Controller
/
Plugin
/
[ Home ]
Create Folder
Create File
Nama File / Folder
Size
Action
CleanQuery.php
3.031KB
Edit File
Delete File
Rename
<?php /** * Plugin that cleans up querystrings in GET submissions * NB : ce plugin ne fonctionne pas lorsque les valeurs des param�tres contiennent des '/' */ class My_Controller_Plugin_CleanQuery extends Zend_Controller_Plugin_Abstract { /** * @var boolean */ protected $permanent; /** * Takes a flag in the constructor to determine whether the redirects * are permanent or just temporary (default); * * @param boolean $permanent */ public function __construct($permanent=true) { $this->permanent=$permanent; } /** * Cleans the GET and if it's changed does a redirect */ public function routeStartup(Zend_Controller_Request_Abstract $request) { // On supprime les param�tres qui n'ont pas de valeur if($this->getRequest()->isGet()) { $params = $this->getRequest()->getParams(); if($params) { $new_params = $this->_filterArray($params); if(count($params, COUNT_RECURSIVE) > count($new_params, COUNT_RECURSIVE)) { // $uri = $this->getRequest()->getRequestUri(); $uri = $_SERVER['REQUEST_URI']; $path = substr($uri, 0, strpos($uri, '?') + 1) . http_build_query($new_params); $this->getResponse()->setRedirect($path, $this->permanent?301:302); $this->getResponse()->sendResponse(); exit; } } } // Si on a des param�tres qui sont pass�s par _GET, on r��crit l'url pour passer des param�tres ZF-Style if (isset($_GET) && is_array($_GET) && !empty($_GET)) { $path = ''; //array_walk($_GET, array(__CLASS__, 'encodeParam')); foreach ($_GET as $key => $value) { if (is_array ($value) ) { foreach ($value as $_value) { $path .= '/' . $key . '/' . $_value; } continue; } if ($key != 'submit') $path .= '/' . $key . '/' . $value; } $uri = $_SERVER['REQUEST_URI']; $path = substr($uri, 0, strpos($uri, '?')) . $path; $this->getResponse()->setRedirect($path, $this->permanent ? 301 : 302); $this->getResponse()->sendResponse(); exit; } } /** * Cleans out false values from an array * * @param array $array */ private function _filterArray($array) { foreach($array as $key=>$value) { if(is_array($value)) { $value = $this->_filterArray($value); $array[$key]=$value; } if($value==='') { unset($array[$key]); } } return $array; } public static function encodeParam(&$value, &$key) { $value = urlencode($value); $key = urlencode($key); } } ?>
Save!!!
© 2022 - 2023 WIBUHAXOR V1 By Lutfifakee || Padang Blackhat