示例#1
1
function cf7bs_number_shortcode_handler($tag)
{
    $tag = new WPCF7_Shortcode($tag);
    if (empty($tag->name)) {
        return '';
    }
    $mode = $status = 'default';
    $validation_error = wpcf7_get_validation_error($tag->name);
    $class = wpcf7_form_controls_class($tag->type);
    $class .= ' wpcf7-validates-as-number';
    if ($validation_error) {
        $class .= ' wpcf7-not-valid';
        $status = 'error';
    }
    if ($tag->is_required()) {
        $mode = 'required';
    }
    $value = (string) reset($tag->values);
    $placeholder = '';
    if ($tag->has_option('placeholder') || $tag->has_option('watermark')) {
        $placeholder = $value;
        $value = '';
    }
    if (wpcf7_is_posted() && isset($_POST[$tag->name])) {
        $value = stripslashes_deep($_POST[$tag->name]);
    } elseif (isset($_GET) && array_key_exists($tag->name, $_GET)) {
        $value = stripslashes_deep(rawurldecode($_GET[$tag->name]));
    }
    $field = new CF7BS_Form_Field(array('name' => $tag->name, 'id' => $tag->get_option('id', 'id', true), 'class' => $tag->get_class_option($class), 'type' => wpcf7_support_html5() ? $tag->basetype : 'text', 'value' => $value, 'placeholder' => $placeholder, 'label' => $tag->content, 'options' => array('min' => $tag->get_option('min', 'signed_int', true), 'max' => $tag->get_option('max', 'signed_int', true), 'step' => $tag->get_option('step', 'int', true)), 'help_text' => $validation_error, 'size' => cf7bs_get_form_property('size'), 'grid_columns' => cf7bs_get_form_property('grid_columns'), 'form_layout' => cf7bs_get_form_property('layout'), 'form_label_width' => cf7bs_get_form_property('label_width'), 'form_breakpoint' => cf7bs_get_form_property('breakpoint'), 'mode' => $mode, 'status' => $status, 'readonly' => $tag->has_option('readonly') ? true : false, 'tabindex' => $tag->get_option('tabindex', 'int', true), 'wrapper_class' => $tag->name));
    $html = $field->display(false);
    return $html;
}
 public function matches(Request $request)
 {
     if (!$this->language) {
         throw new \LogicException('Unable to match the request as the expression language is not available.');
     }
     return $this->language->evaluate($this->expression, array('request' => $request, 'method' => $request->getMethod(), 'path' => rawurldecode($request->getPathInfo()), 'host' => $request->getHost(), 'ip' => $request->getClientIp(), 'attributes' => $request->attributes->all())) && parent::matches($request);
 }
 function items($name = '', $payload = '')
 {
     // Protect this handler
     if (!$this->authorized()) {
         redirect('auth/login');
     }
     $data['profile_items'] = array();
     $data['name'] = 'No item';
     if ($name) {
         $name = rawurldecode($name);
         $profile_item_obj = new Profile_model();
         $data['profile_name'] = $name;
         if ($payload) {
             $payload = rawurldecode($payload);
             $items = $profile_item_obj->retrieve_many('payload_name = ? GROUP BY serial_number', array($payload));
             $data['name'] = $payload;
         } else {
             $items = $profile_item_obj->retrieve_many('profile_name = ? GROUP BY serial_number', array($name));
             $data['name'] = $name;
         }
         foreach ($items as $item) {
             $machine = new Machine_model($item->serial_number);
             $instance['serial'] = $item->serial_number;
             $instance['hostname'] = $machine->computer_name;
             $instance['payload'] = $item->profile_name;
             $data['profile_items'][] = $instance;
         }
     }
     $obj = new View();
     $obj->view('profile/profileitem_detail', $data);
 }
 function extractRDF()
 {
     $tc = 0;
     $t = '';
     $t_vals = array();
     foreach ($this->nodes as $n) {
         if ($n['tag'] != 'a') {
             continue;
         }
         if (!($href = $this->v('href uri', '', $n['a']))) {
             continue;
         }
         if (!($rels = $this->v('rel m', array(), $n['a']))) {
             continue;
         }
         if (!($vals = array_intersect($this->terms, $rels))) {
             continue;
         }
         $parts = preg_match('/^(.*\\/)([^\\/]+)\\/?$/', $href, $m) ? array('space' => $m[1], 'tag' => rawurldecode($m[2])) : array('space' => '', 'tag' => '');
         if ($tag = $parts['tag']) {
             $t_vals['s_' . $tc] = $this->getContainerResIDByClass($n, $this->containers);
             $t_vals['concept_' . $tc] = $this->createBnodeID() . '_concept';
             $t_vals['tag_' . $tc] = $tag;
             $t_vals['space_' . $tc] = $parts['space'];
             $t .= '?s_' . $tc . ' skos:subject [skos:prefLabel ?tag_' . $tc . ' ; skos:inScheme ?space_' . $tc . '] . ';
             $tc++;
         }
     }
     $doc = $this->getFilledTemplate($t, $t_vals, $n['doc_base']);
     $this->addTs(ARC2::getTriplesFromIndex($doc));
 }
示例#5
0
 public function match($pathinfo)
 {
     $allow = array();
     $pathinfo = rawurldecode($pathinfo);
     $context = $this->context;
     $request = $this->request;
     if (0 === strpos($pathinfo, '/noticias')) {
         // noticias
         if (rtrim($pathinfo, '/') === '/noticias') {
             if (substr($pathinfo, -1) !== '/') {
                 return $this->redirect($pathinfo . '/', 'noticias');
             }
             return array('_controller' => 'uni\\bundle\\marcaBundle\\Controller\\noticiasController::indexAction', '_route' => 'noticias');
         }
         // noticias_show
         if (preg_match('#^/noticias/(?P<id>[^/]++)/show$#s', $pathinfo, $matches)) {
             return $this->mergeDefaults(array_replace($matches, array('_route' => 'noticias_show')), array('_controller' => 'uni\\bundle\\marcaBundle\\Controller\\noticiasController::showAction'));
         }
         // noticias_new
         if ($pathinfo === '/noticias/new') {
             return array('_controller' => 'uni\\bundle\\marcaBundle\\Controller\\noticiasController::newAction', '_route' => 'noticias_new');
         }
         // noticias_create
         if ($pathinfo === '/noticias/create') {
             if ($this->context->getMethod() != 'POST') {
                 $allow[] = 'POST';
                 goto not_noticias_create;
             }
             return array('_controller' => 'uni\\bundle\\marcaBundle\\Controller\\noticiasController::createAction', '_route' => 'noticias_create');
         }
         not_noticias_create:
         // noticias_edit
         if (preg_match('#^/noticias/(?P<id>[^/]++)/edit$#s', $pathinfo, $matches)) {
             return $this->mergeDefaults(array_replace($matches, array('_route' => 'noticias_edit')), array('_controller' => 'uni\\bundle\\marcaBundle\\Controller\\noticiasController::editAction'));
         }
         // noticias_update
         if (preg_match('#^/noticias/(?P<id>[^/]++)/update$#s', $pathinfo, $matches)) {
             if (!in_array($this->context->getMethod(), array('POST', 'PUT'))) {
                 $allow = array_merge($allow, array('POST', 'PUT'));
                 goto not_noticias_update;
             }
             return $this->mergeDefaults(array_replace($matches, array('_route' => 'noticias_update')), array('_controller' => 'uni\\bundle\\marcaBundle\\Controller\\noticiasController::updateAction'));
         }
         not_noticias_update:
         // noticias_delete
         if (preg_match('#^/noticias/(?P<id>[^/]++)/delete$#s', $pathinfo, $matches)) {
             if (!in_array($this->context->getMethod(), array('POST', 'DELETE'))) {
                 $allow = array_merge($allow, array('POST', 'DELETE'));
                 goto not_noticias_delete;
             }
             return $this->mergeDefaults(array_replace($matches, array('_route' => 'noticias_delete')), array('_controller' => 'uni\\bundle\\marcaBundle\\Controller\\noticiasController::deleteAction'));
         }
         not_noticias_delete:
         // uni_marca_homepage
         if ($pathinfo === '/noticias') {
             return array('_controller' => 'uni\\bundle\\marcaBundle\\Controller\\DefaultController::indexAction', '_route' => 'uni_marca_homepage');
         }
     }
     throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
 }
示例#6
0
 public function match($pathinfo)
 {
     $allow = array();
     $pathinfo = rawurldecode($pathinfo);
     $context = $this->context;
     $request = $this->request;
     if (0 === strpos($pathinfo, '/blog')) {
         // cl_blog_home
         if (preg_match('#^/blog(?:/(?P<page>\\d*))?$#s', $pathinfo, $matches)) {
             return $this->mergeDefaults(array_replace($matches, array('_route' => 'cl_blog_home')), array('_controller' => 'CL\\BlogBundle\\Controller\\AdvertController::indexAction', 'page' => 1));
         }
         if (0 === strpos($pathinfo, '/blog/ad')) {
             // cl_blog_view
             if (0 === strpos($pathinfo, '/blog/advert') && preg_match('#^/blog/advert/(?P<id>\\d+)$#s', $pathinfo, $matches)) {
                 return $this->mergeDefaults(array_replace($matches, array('_route' => 'cl_blog_view')), array('_controller' => 'CL\\BlogBundle\\Controller\\AdvertController::viewAction'));
             }
             // cl_blog_add
             if ($pathinfo === '/blog/add') {
                 return array('_controller' => 'CL\\BlogBundle\\Controller\\AdvertController::addAction', '_route' => 'cl_blog_add');
             }
         }
         // cl_blog_edit
         if (0 === strpos($pathinfo, '/blog/edit') && preg_match('#^/blog/edit/(?P<id>\\d+)$#s', $pathinfo, $matches)) {
             return $this->mergeDefaults(array_replace($matches, array('_route' => 'cl_blog_edit')), array('_controller' => 'CL\\BlogBundle\\Controller\\AdvertController::editAction'));
         }
         // cl_blog_delete
         if (0 === strpos($pathinfo, '/blog/delete') && preg_match('#^/blog/delete/(?P<id>\\d+)$#s', $pathinfo, $matches)) {
             return $this->mergeDefaults(array_replace($matches, array('_route' => 'cl_blog_delete')), array('_controller' => 'CL\\BlogBundle\\Controller\\AdvertController::deleteAction'));
         }
     }
     throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
 }
示例#7
0
 public function action($what, $cat, &$ret, $limit, $useGlobalCats)
 {
     $category = !$useGlobalCats && $cat && array_key_exists($cat, $this->categories) ? $this->categories[$cat] : $this->categories['all'];
     $searchUrl = $this->url . '/browse.php?search=' . $what . '&page=0&cat=' . $category;
     $cli = $this->fetch($searchUrl, false);
     if (!$cli) {
         $this->sendSimpleResult('error', 'Error connecting to bitsoup', $ret);
         return;
     }
     if (strpos($cli->results, '<h2>Search results for "' . rawurldecode($what) . '"</h2>') === false) {
         $this->sendSimpleResult('noresults', 'No results could be parsed from Bitsoup', $ret);
         return;
     }
     list($totalRowCount, $rows) = $this->countRows($cli->results);
     if ($totalRowCount === null) {
         $this->sendSimpleResult('noresults', 'Result table could not be parsed from Bitsoup', $ret);
         return;
     }
     if ($totalRowCount === 0) {
         $this->sendSimpleResult('noresults', 'No results found', $ret);
         return;
     }
     list($rowsParsed, $unMatchedRows) = $this->processResults($rows, $ret);
     if ($rowsParsed === null) {
         $this->sendSimpleResult('noresults', 'No results could be parsed from Bitsoup', $ret);
         return;
     }
     if ($rowsParsed < $totalRowCount) {
         $this->sendSimpleResult('resultCount', 'Warning: detected ' . $totalRowCount . ' but could parsed just ' . $rowsParsed . ' results', $ret, $this->getDataUrlForUnmatchedRows($unMatchedRows));
     }
 }
 public function addAuthHeaders(BeforeEvent $event)
 {
     /*
      * Get Consumer ID and Private Key from auth and then unset it
      */
     $auth = $event->getClient()->getDefaultOption('auth');
     if ($auth === null) {
         throw new \Exception('Http client is missing \'auth\' parameters', 1466965269);
     }
     $consumerId = $auth[0];
     $privateKey = $auth[1];
     $event->getClient()->setDefaultOption('auth', null);
     /*
      * Get Request URL, method, and timestamp to calculate signature
      */
     $requestUrl = $event->getRequest()->getUrl();
     //decode url back to normal to nextCursor issue. automatic url encoding
     $requestUrl = rawurldecode($requestUrl);
     $event->getRequest()->setUrl($requestUrl);
     $requestMethod = $event->getRequest()->getMethod();
     $timestamp = Utils::getMilliseconds();
     $signature = Signature::calculateSignature($consumerId, $privateKey, $requestUrl, $requestMethod, $timestamp);
     /*
      * Add required headers to request
      */
     $headers = ['WM_SVC.NAME' => 'Walmart Marketplace', 'WM_QOS.CORRELATION_ID' => base64_encode(Random::string(16)), 'WM_SEC.TIMESTAMP' => $timestamp, 'WM_SEC.AUTH_SIGNATURE' => $signature, 'WM_CONSUMER.ID' => $consumerId];
     $currentHeaders = $event->getRequest()->getHeaders();
     unset($currentHeaders['Authorization']);
     $updatedHeaders = array_merge($currentHeaders, $headers);
     $event->getRequest()->setHeaders($updatedHeaders);
 }
示例#9
0
 /**
  * Tries to find a route matching the current request. If found the defined action is called.
  */
 protected function dispatch()
 {
     $httpMethod = $_SERVER['REQUEST_METHOD'];
     $uri = rawurldecode(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
     $routeInfo = $this->dispatcher->dispatch($httpMethod, $uri);
     if (!isset($routeInfo[0])) {
         throw new RuntimeException('Could not dispatch request.');
     }
     switch ($routeInfo[0]) {
         case FastRoute\Dispatcher::NOT_FOUND:
             $responder = new NotFoundResponder($this->config);
             $responder->__invoke();
             break;
         case FastRoute\Dispatcher::METHOD_NOT_ALLOWED:
             $responder = new HttpResponder($this->config);
             $responder->methodNotAllowed();
             break;
         case FastRoute\Dispatcher::FOUND:
             $handler = $routeInfo[1];
             $arguments = $routeInfo[2];
             $this->runAction($handler, $arguments);
             break;
         default:
             throw new RuntimeException('Could not dispatch request.');
     }
 }
示例#10
0
/**
 * Smarty plugin
 * -------------------------------------------------------------
 * File: insert.oxid_nocache.php
 * Type: string, html
 * Name: oxid_nocache
 * Purpose: Inserts Items not cached
 * -------------------------------------------------------------
 *
 * @param array  $params  params
 * @param Smarty &$smarty clever simulation of a method
 *
 * @return string
 */
function smarty_insert_oxid_nocache($params, &$smarty)
{
    $myConfig = oxRegistry::getConfig();
    $smarty->caching = false;
    /* if( isset( $smarty->oxobject->oProduct))
       $smarty->assign_by_ref( "product", $smarty->oxobject->oProduct);*/
    // #1184M - specialchar search
    $sSearchParamForHTML = oxRegistry::getConfig()->getRequestParameter("searchparam");
    $sSearchParamForLink = rawurlencode(oxRegistry::getConfig()->getRequestParameter("searchparam", true));
    if ($sSearchParamForHTML) {
        $smarty->assign_by_ref("searchparamforhtml", $sSearchParamForHTML);
        $smarty->assign_by_ref("searchparam", $sSearchParamForLink);
    }
    $sSearchCat = oxRegistry::getConfig()->getRequestParameter("searchcnid");
    if ($sSearchCat) {
        $smarty->assign_by_ref("searchcnid", rawurldecode($sSearchCat));
    }
    foreach (array_keys($params) as $key) {
        $viewData =& $params[$key];
        $smarty->assign_by_ref($key, $viewData);
    }
    $sOutput = $smarty->fetch($params['tpl']);
    $smarty->caching = false;
    return $sOutput;
}
示例#11
0
 function execute($par)
 {
     global $wgRequest, $wgEmailImage;
     $size = 4;
     $text = $wgRequest->getText('img');
     /* decode this rubbish */
     $text = rawurldecode($text);
     $text = str_rot13($text);
     $text = base64_decode($text);
     $text = str_replace($wgEmailImage['ugly'], "", $text);
     $fontwidth = imagefontwidth($size);
     $fontheight = imagefontheight($size);
     $width = strlen($text) * $fontwidth + 4;
     $height = $fontheight + 2;
     $im = @imagecreatetruecolor($width, $height) or exit;
     $trans = imagecolorallocate($im, 0, 0, 0);
     /* must be black! */
     $color = imagecolorallocate($im, 1, 1, 1);
     /* nearly black ;) */
     imagecolortransparent($im, $trans);
     /* seems to work only with black! */
     imagestring($im, $size, 2, 0, $text, $color);
     //header ("Content-Type: image/png"); imagepng($im); => IE is just so bad!
     header("Content-Type: image/gif");
     imagegif($im);
     exit;
 }
示例#12
0
 public function vote(TokenInterface $token, $object, array $attributes)
 {
     $request = null;
     try {
         $request = $this->app['request'];
     } catch (\RuntimeException $e) {
         // requestが取得できない場合、無視する(テストプログラムで不要なため)
         return;
     }
     $path = rawurldecode($request->getPathInfo());
     $Member = $this->app->user();
     if ($Member instanceof \Eccube\Entity\Member) {
         // 管理者のロールをチェック
         $AuthorityRoles = $this->app['eccube.repository.authority_role']->findBy(array('Authority' => $Member->getAuthority()));
         foreach ($AuthorityRoles as $AuthorityRole) {
             // 許可しないURLが含まれていればアクセス拒否
             try {
                 // 正規表現でURLチェック
                 $denyUrl = str_replace('/', '\\/', $AuthorityRole->getDenyUrl());
                 if (preg_match("/^(\\/{$this->app['config']['admin_route']}{$denyUrl})/i", $path)) {
                     return VoterInterface::ACCESS_DENIED;
                 }
             } catch (\Exception $e) {
                 // 拒否URLの指定に誤りがある場合、エスケープさせてチェック
                 $denyUrl = preg_quote($AuthorityRole->getDenyUrl(), '/');
                 if (preg_match("/^(\\/{$this->app['config']['admin_route']}{$denyUrl})/i", $path)) {
                     return VoterInterface::ACCESS_DENIED;
                 }
             }
         }
     }
     return VoterInterface::ACCESS_GRANTED;
 }
示例#13
0
 public static function createTorrent($torrent, $hash)
 {
     global $saveUploadedTorrents;
     $torrent = new Torrent($torrent);
     if ($torrent->errors()) {
         return self::STE_DELETED;
     }
     if ($torrent->hash_info() == $hash) {
         return self::STE_UPTODATE;
     }
     $req = new rXMLRPCRequest(array(new rXMLRPCCommand("d.get_directory_base", $hash), new rXMLRPCCommand("d.get_custom1", $hash), new rXMLRPCCommand("d.get_throttle_name", $hash), new rXMLRPCCommand("d.get_connection_seed", $hash), new rXMLRPCCommand("d.is_open", $hash), new rXMLRPCCommand("d.is_active", $hash), new rXMLRPCCommand("d.get_state", $hash), new rXMLRPCCommand("d.stop", $hash), new rXMLRPCCommand("d.close", $hash)));
     if ($req->success()) {
         $addition = array(getCmd("d.set_connection_seed=") . $req->val[3], getCmd("d.set_custom") . "=chk-state," . self::STE_UPDATED, getCmd("d.set_custom") . "=chk-time," . time(), getCmd("d.set_custom") . "=chk-stime," . time());
         $isStart = $req->val[4] != 0 && $req->val[5] != 0 && $req->val[6] != 0;
         if (!empty($req->val[2])) {
             $addition[] = getCmd("d.set_throttle_name=") . $req->val[2];
         }
         if (preg_match('/rat_(\\d+)/', $req->val[3], $ratio)) {
             $addition[] = getCmd("view.set_visible=") . "rat_" . $ratio;
         }
         $label = rawurldecode($req->val[1]);
         if (rTorrent::sendTorrent($torrent, $isStart, false, $req->val[0], $label, $saveUploadedTorrents, false, true, $addition)) {
             $req = new rXMLRPCRequest(new rXMLRPCCommand("d.erase", $hash));
             if ($req->success()) {
                 return null;
             }
         }
     }
     return self::STE_ERROR;
 }
示例#14
0
 /**
  * url字符串转化为数组格式
  * 
  * 效果同'argsToUrl'相反
  * @param string $url
  * @param boolean $decode 是否需要进行url反编码处理
  * @param string $separator url的分隔符
  * @return array
  */
 public static function urlToArgs($url, $decode = true, $separator = '&=')
 {
     if (strlen($separator) !== 2) {
         return array();
     }
     if (false !== ($pos = strpos($url, '?'))) {
         $url = substr($url, $pos + 1);
     }
     $url = explode($separator[0], trim($url, $separator[0]));
     $args = array();
     if ($separator[0] === $separator[1]) {
         $_count = count($url);
         for ($i = 0; $i < $_count; $i += 2) {
             if (!isset($url[$i + 1])) {
                 $args[] = $decode ? rawurldecode($url[$i]) : $url[$i];
                 continue;
             }
             $_k = $decode ? rawurldecode($url[$i]) : $url[$i];
             $_v = $decode ? rawurldecode($url[$i + 1]) : $url[$i + 1];
             $args[$_k] = $_v;
         }
     } else {
         foreach ($url as $value) {
             if (strpos($value, $separator[1]) === false) {
                 $args[] = $decode ? rawurldecode($value) : $value;
                 continue;
             }
             list($__k, $__v) = explode($separator[1], $value);
             $args[$__k] = $decode && $__v ? rawurldecode($__v) : $__v;
         }
     }
     return $args;
 }
示例#15
0
 public function set()
 {
     if (!isset($HTTP_RAW_POST_DATA)) {
         $HTTP_RAW_POST_DATA = file_get_contents("php://input");
     }
     if (isset($HTTP_RAW_POST_DATA)) {
         $vars = explode('&', $HTTP_RAW_POST_DATA);
         $this->list = array();
         foreach ($vars as $var) {
             $parts = explode("=", $var);
             if ($parts[0] == "look") {
                 $value = trim(rawurldecode($parts[1]));
                 if (strlen($value)) {
                     $tmp = explode("|", $value);
                     if (count($tmp > 1) && trim($tmp[1]) != '') {
                         if (strpos($tmp[1], "{title}") === false) {
                             $tmp[1] .= "{title}";
                         }
                         $this->list[$tmp[0]] = $tmp[1];
                     }
                 }
             }
         }
     }
     $this->store();
 }
示例#16
0
function fma_filter($type, $filename, $Extension)
{
    $autorise = false;
    $error = "";
    if ($type == "f") {
        $filename = removeHack($filename);
    }
    $filename = preg_replace('#[/\\\\:\\*\\?"<>|]#i', '', rawurldecode($filename));
    $filename = str_replace("..", "", $filename);
    // Liste des extensions autorisées
    $suffix = strtoLower(substr(strrchr($filename, '.'), 1));
    if ($suffix != "" or $type == "d") {
        if (in_array($suffix, $Extension) or $Extension[0] == "*" or $type == "d") {
            // Fichiers interdits en fonction de qui est connecté
            if (fma_autorise($type, $filename)) {
                $autorise = true;
            } else {
                $error = fma_translate("Fichier interdit");
            }
        } else {
            $error = fma_translate("Type de fichier interdit");
        }
    } else {
        $error = fma_translate("Fichier interdit");
    }
    $tab[] = $autorise;
    $tab[] = $error;
    $tab[] = $filename;
    return $tab;
}
示例#17
0
 public function action($what, $cat, &$ret, $limit, $useGlobalCats)
 {
     $added = 0;
     $url = 'http://rutracker.org';
     if ($useGlobalCats) {
         $categories = array('all' => '&f[]=-1', 'games' => '&f[]=5&f[]=635&f[]=139&f[]=959&f[]=127&f[]=53&f[]=1008&f[]=51&f[]=961&f[]=962&f[]=54&f[]=55&f[]=52&f[]=900&f[]=246&f[]=278&f[]=128&f[]=2115&f[]=2116&f[]=2117&f[]=2118&f[]=2119&f[]=50&f[]=2142&f[]=2143&f[]=2145&f[]=2146&f[]=637&f[]=642&f[]=643&f[]=644&f[]=645&f[]=646&f[]=647&f[]=649&f[]=1098&f[]=650&f[]=548&f[]=129&f[]=908&f[]=357&f[]=510&f[]=887&f[]=1116&f[]=973&f[]=773&f[]=774&f[]=968&f[]=546', 'anime' => '&f[]=33&f[]=281&f[]=1386&f[]=1387&f[]=1388&f[]=282&f[]=599&f[]=1105&f[]=1389&f[]=404&f[]=1390&f[]=1642&f[]=1391&f[]=893&f[]=1478', 'pictures' => 'f[]=1100&f[]=1643&f[]=848&f[]=808&f[]=630&f[]=1664');
     } else {
         $categories =& $this->categories;
     }
     if (!array_key_exists($cat, $categories)) {
         $cat = $categories['all'];
     } else {
         $cat = $categories[$cat];
     }
     $what = rawurlencode(self::fromUTF(rawurldecode($what), "CP1251"));
     $cli = $this->fetch($url . '/forum/tracker.php');
     // just for login
     $cli = $this->fetch($url . '/forum/tracker.php', 0, "POST", "application/x-www-form-urlencoded", 'prev_my=0&prev_new=0&prev_oop=1' . $cat . '&o=10&s=2&oop=1&nm=' . $what . '&submit=%CF%EE%E8%F1%EA');
     if ($cli !== false && $this->parseTList($cli->results, $added, $ret, $limit)) {
         $res = preg_match_all('/<a class="pg" href="tracker.php\\?search_id=(?P<next>[^"]*)">/siU', $cli->results, $next);
         $next = array_unique($next["next"]);
         for ($pg = 0; $pg < count($next); $pg++) {
             $cli = $this->fetch($url . '/forum/tracker.php?search_id=' . self::removeTags($next[$pg]));
             if ($cli == false || !$this->parseTList($cli->results, $added, $ret, $limit)) {
                 break;
             }
         }
     }
 }
 /**
  * Parse a query string into a QueryString object
  *
  * @param string $query Query string to parse
  *
  * @return self
  */
 public static function fromString($query)
 {
     $q = new static();
     if (0 !== strlen($query)) {
         if ($query[0] == '?') {
             $query = substr($query, 1);
         }
         foreach (explode('&', $query) as $kvp) {
             $parts = explode('=', $kvp, 2);
             $key = rawurldecode($parts[0]);
             $paramIsPhpStyleArray = substr($key, -2) == '[]';
             if ($paramIsPhpStyleArray) {
                 $key = substr($key, 0, -2);
             }
             if (array_key_exists(1, $parts)) {
                 $value = rawurldecode(str_replace('+', '%20', $parts[1]));
                 if ($paramIsPhpStyleArray && !$q->hasKey($key)) {
                     $value = array($value);
                 }
                 $q->add($key, $value);
             } else {
                 $q->add($key, '');
             }
         }
     }
     return $q;
 }
 function isvalidSession($htoken, $maxidletime = 0, $checkip = false)
 {
     global $cfg;
     $token = rawurldecode($htoken);
     #check if we got what we expected....
     if ($token && !strstr($token, ":")) {
         return FALSE;
     }
     #get the goodies
     list($hash, $expire, $ip) = explode(":", $token);
     #Make sure the session hash is valid
     if (md5($expire . SESSION_SECRET . $this->userID) != $hash) {
         return FALSE;
     }
     #is it expired??
     if ($maxidletime && time() - $expire > $maxidletime) {
         return FALSE;
     }
     #Make sure IP is still same ( proxy access??????)
     if ($checkip && strcmp($ip, MD5($this->ip))) {
         return FALSE;
     }
     $this->validated = TRUE;
     return TRUE;
 }
示例#20
0
 public static function gzd_json_search_delivery_time()
 {
     ob_start();
     check_ajax_referer('search-products', 'security');
     $term = (string) wc_clean(stripslashes($_GET['term']));
     $terms = array();
     if (empty($term)) {
         die;
     }
     $args = array('hide_empty' => false);
     if (is_numeric($term)) {
         $args['include'] = array(absint($term));
     } else {
         $args['name__like'] = (string) $term;
     }
     $query = get_terms('product_delivery_time', $args);
     if (!empty($query)) {
         foreach ($query as $term) {
             $terms[$term->term_id] = rawurldecode($term->name);
         }
     } else {
         $terms[rawurldecode($term)] = rawurldecode(sprintf(__("%s [new]", "woocommerce-germanized"), $term));
     }
     wp_send_json($terms);
 }
示例#21
0
 /**
  * Parse a query string into a Query object
  *
  * @param string $query Query string to parse
  *
  * @return self
  */
 public static function fromString($query)
 {
     $q = new static();
     if ($query === '') {
         return $q;
     }
     $foundDuplicates = $foundPhpStyle = false;
     foreach (explode('&', $query) as $kvp) {
         $parts = explode('=', $kvp, 2);
         $key = rawurldecode($parts[0]);
         if ($paramIsPhpStyleArray = substr($key, -2) == '[]') {
             $foundPhpStyle = true;
             $key = substr($key, 0, -2);
         }
         if (isset($parts[1])) {
             $value = rawurldecode(str_replace('+', '%20', $parts[1]));
             if (isset($q[$key])) {
                 $q->add($key, $value);
                 $foundDuplicates = true;
             } elseif ($paramIsPhpStyleArray) {
                 $q[$key] = array($value);
             } else {
                 $q[$key] = $value;
             }
         } else {
             $q->add($key, null);
         }
     }
     // Use the duplicate aggregator if duplicates were found and not using
     // PHP style arrays.
     if ($foundDuplicates && !$foundPhpStyle) {
         $q->setAggregator(self::duplicateAggregator());
     }
     return $q;
 }
 /**
  +----------------------------------------------------------
 * 解密字符串
  +----------------------------------------------------------
 * @access static
  +----------------------------------------------------------
 * @param string $str 字符串
 * @param string $key 加密key
  +----------------------------------------------------------
 * @return string
  +----------------------------------------------------------
 * @throws ThinkExecption
  +----------------------------------------------------------
 */
 public static function decrypt($str, $key)
 {
     if ($str == '') {
         return '';
     }
     $str = base64_decode(rawurldecode($str));
     $v = self::str2long($str, false);
     $k = self::str2long($key, false);
     $n = count($v) - 1;
     if ($n == -1) {
         return '';
     }
     $z = isset($v[$n]) ? $v[$n] : '';
     $y = isset($v[0]) ? $v[0] : '';
     $delta = 0x9e3779b9;
     $q = floor(6 + 52 / ($n + 1));
     $sum = self::int32($q * $delta);
     while ($sum != 0) {
         $e = $sum >> 2 & 3;
         for ($p = $n; $p > 0; $p--) {
             $z = isset($v[$p - 1]) ? $v[$p - 1] : '';
             $v[$p] = isset($v[$p]) ? $v[$p] : '';
             $mx = self::int32(($z >> 5 & 0x7ffffff ^ $y << 2) + ($y >> 3 & 0x1fffffff ^ $z << 4)) ^ self::int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
             $y = $v[$p] = self::int32($v[$p] - $mx);
         }
         $z = $v[$n];
         $mx = self::int32(($z >> 5 & 0x7ffffff ^ $y << 2) + ($y >> 3 & 0x1fffffff ^ $z << 4)) ^ self::int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
         $y = $v[0] = self::int32($v[0] - $mx);
         $sum = self::int32($sum - $delta);
     }
     return json_decode(self::long2str($v, true), true);
 }
示例#23
0
 /**
  * Generates the index file for the admin interface.
  */
 public function indexAction()
 {
     $cssHeader = '';
     $abslen = strlen(PATH_site);
     $langid = $this->getContext()->getLocale()->getLanguageId();
     $controller = $this->getController();
     foreach (Base::getAimeos()->getCustomPaths('client/extjs') as $base => $paths) {
         $relJsbPath = '../' . substr($base, $abslen);
         foreach ($paths as $path) {
             $jsbAbsPath = $base . '/' . $path;
             if (!is_file($jsbAbsPath)) {
                 throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath));
             }
             $jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, $relJsbPath . '/' . dirname($path));
             $cssHeader .= $jsb2->getHtml('css');
         }
     }
     // rawurldecode() is necessary for ExtJS templates to replace "{site}" properly
     $urlTemplate = rawurldecode(BackendUtility::getModuleUrl($this->request->getPluginName(), array('tx_aimeos_web_aimeostxaimeosadmin' => array('site' => '{site}', 'tab' => '{tab}'))));
     $serviceUrl = BackendUtility::getModuleUrl($this->request->getPluginName(), array('tx_aimeos_web_aimeostxaimeosadmin' => array('controller' => 'Admin', 'action' => 'do')));
     $this->view->assign('cssHeader', $cssHeader);
     $this->view->assign('lang', $langid);
     $this->view->assign('i18nContent', $this->getJsonClientI18n($langid));
     $this->view->assign('config', $this->getJsonClientConfig());
     $this->view->assign('site', $this->getSite($this->request));
     $this->view->assign('smd', $controller->getJsonSmd($serviceUrl));
     $this->view->assign('itemSchemas', $controller->getJsonItemSchemas());
     $this->view->assign('searchSchemas', $controller->getJsonSearchSchemas());
     $this->view->assign('activeTab', $this->request->hasArgument('tab') ? (int) $this->request->getArgument('tab') : 0);
     $this->view->assign('version', $this->getVersion());
     $this->view->assign('urlTemplate', $urlTemplate);
 }
 public function run($tid, $act = 'apply')
 {
     $res = WebUtils::initWebApiArray_oldVersion();
     $uid = $this->getController()->uid;
     // $_REQUEST['json'] = "{'payment':1,'payvalue':100, 'realname': '请求参数11', 'qq': '8', 'message': '请求参数'}";
     $json = isset($_REQUEST['json']) ? $_REQUEST['json'] : '';
     $json = rawurldecode($json);
     $data = WebUtils::jsonDecode($json);
     if (!empty($data)) {
         foreach ($data as $key => $value) {
             if (is_string($value)) {
                 $data[$key] = WebUtils::t($value);
             }
         }
         switch ($act) {
             case 'apply':
                 $res = $this->_applyActivityTopic($res, $tid, $uid, $data);
                 break;
             case 'cancel':
                 $res = $this->_cancelActivityTopic($res, $tid, $uid, $data);
                 break;
             default:
                 $res = $this->_makeErrorInfo($res, 'activity_apply_params_error');
                 break;
         }
     } else {
         $res = $this->_makeErrorInfo($res, 'activity_apply_params_error');
     }
     echo WebUtils::outputWebApi($res, '', false);
 }
示例#25
0
 /**
  * {@inheritdoc}
  */
 protected function doFetch(array $ids)
 {
     $values = array();
     $now = time();
     foreach ($ids as $id) {
         $file = $this->getFile($id);
         if (!($h = @fopen($file, 'rb'))) {
             continue;
         }
         if ($now >= (int) ($expiresAt = fgets($h))) {
             fclose($h);
             if (isset($expiresAt[0])) {
                 @unlink($file);
             }
         } else {
             $i = rawurldecode(rtrim(fgets($h)));
             $value = stream_get_contents($h);
             fclose($h);
             if ($i === $id) {
                 $values[$id] = unserialize($value);
             }
         }
     }
     return $values;
 }
        function display_ultimate_map($atts, $content = null)
        {
            $width = $height = $map_type = $lat = $lng = $zoom = $streetviewcontrol = $maptypecontrol = $top_margin = $pancontrol = $zoomcontrol = $zoomcontrolsize = $dragging = $marker_icon = $icon_img = $map_override = $output = $map_style = $scrollwheel = $el_class = '';
            extract(shortcode_atts(array("width" => "100%", "height" => "300px", "map_type" => "ROADMAP", "lat" => "18.591212", "lng" => "73.741261", "zoom" => "14", "scrollwheel" => "", "streetviewcontrol" => "false", "maptypecontrol" => "false", "pancontrol" => "false", "zoomcontrol" => "false", "zoomcontrolsize" => "SMALL", "dragging" => "true", "marker_icon" => "default", "icon_img" => "", "top_margin" => "page_margin_top", "map_override" => "0", "map_style" => "", "el_class" => "", "infowindow_open" => "", "map_vc_template" => ""), $atts));
            $marker_lat = $lat;
            $marker_lng = $lng;
            if ($marker_icon == "default_self") {
                $icon_url = plugins_url("../assets/img/icon-marker-pink.png", __FILE__);
            } elseif ($marker_icon == "default") {
                $icon_url = "";
            } else {
                $icon_url = apply_filters('ult_get_img_single', $icon_img, 'url');
            }
            $id = "map_" . uniqid();
            $wrap_id = "wrap_" . $id;
            $map_type = strtoupper($map_type);
            $width = substr($width, -1) != "%" && substr($width, -2) != "px" ? $width . "px" : $width;
            $map_height = substr($height, -1) != "%" && substr($height, -2) != "px" ? $height . "px" : $height;
            $margin_css = '';
            if ($top_margin != 'none') {
                $margin_css = $top_margin;
            }
            if ($map_vc_template == 'map_vc_template_value') {
                $el_class .= 'uvc-boxed-layout';
            }
            $output .= "<div id='" . $wrap_id . "' class='ultimate-map-wrapper " . $el_class . "' style='" . ($map_height != "" ? "height:" . $map_height . ";" : "") . "'><div id='" . $id . "' data-map_override='" . $map_override . "' class='ultimate_google_map wpb_content_element " . $margin_css . "'" . ($width != "" || $map_height != "" ? " style='" . ($width != "" ? "width:" . $width . ";" : "") . ($map_height != "" ? "height:" . $map_height . ";" : "") . "'" : "") . "></div></div>";
            if ($scrollwheel == "disable") {
                $scrollwheel = 'false';
            } else {
                $scrollwheel = 'true';
            }
            $output .= "<script type='text/javascript'>\n\t\t\t(function(\$) {\n  \t\t\t'use strict';\n\t\t\tvar map_{$id} = null;\n\t\t\tvar coordinate_{$id};\n\t\t\tvar isDraggable = \$(document).width() > 641 ? true : {$dragging};\n\t\t\ttry\n\t\t\t{\n\t\t\t\tvar map_{$id} = null;\n\t\t\t\tvar coordinate_{$id};\n\t\t\t\tcoordinate_{$id}=new google.maps.LatLng({$lat}, {$lng});\n\t\t\t\tvar mapOptions=\n\t\t\t\t{\n\t\t\t\t\tzoom: {$zoom},\n\t\t\t\t\tcenter: coordinate_{$id},\n\t\t\t\t\tscaleControl: true,\n\t\t\t\t\tstreetViewControl: {$streetviewcontrol},\n\t\t\t\t\tmapTypeControl: {$maptypecontrol},\n\t\t\t\t\tpanControl: {$pancontrol},\n\t\t\t\t\tzoomControl: {$zoomcontrol},\n\t\t\t\t\tscrollwheel: {$scrollwheel},\n\t\t\t\t\tdraggable: isDraggable,\n\t\t\t\t\tzoomControlOptions: {\n\t\t\t\t\t  style: google.maps.ZoomControlStyle.{$zoomcontrolsize}\n\t\t\t\t\t},";
            if ($map_style == "") {
                $output .= "mapTypeId: google.maps.MapTypeId.{$map_type},";
            } else {
                $output .= " mapTypeControlOptions: {\n\t\t\t\t\t  \t\tmapTypeIds: [google.maps.MapTypeId.{$map_type}, 'map_style']\n\t\t\t\t\t\t}";
            }
            $output .= "};";
            if ($map_style !== "") {
                $output .= 'var styles = ' . rawurldecode(base64_decode(strip_tags($map_style))) . ';
						var styledMap = new google.maps.StyledMapType(styles,
					    	{name: "Styled Map"});';
            }
            $output .= "var map_{$id} = new google.maps.Map(document.getElementById('{$id}'),mapOptions);";
            if ($map_style !== "") {
                $output .= "map_{$id}.mapTypes.set('map_style', styledMap);\n \t\t\t\t\t\t\t map_{$id}.setMapTypeId('map_style');";
            }
            if ($marker_lat != "" && $marker_lng != "") {
                $output .= "\n\t\t\t\t\t\tvar x = '" . $infowindow_open . "';\n\t\t\t\t\t\tvar marker_{$id} = new google.maps.Marker({\n\t\t\t\t\t\tposition: new google.maps.LatLng({$marker_lat}, {$marker_lng}),\n\t\t\t\t\t\tanimation:  google.maps.Animation.DROP,\n\t\t\t\t\t\tmap: map_{$id},\n\t\t\t\t\t\ticon: '" . $icon_url . "'\n\t\t\t\t\t});\n\t\t\t\t\tgoogle.maps.event.addListener(marker_{$id}, 'click', toggleBounce);";
                if (trim($content) !== "") {
                    $output .= "var infowindow = new google.maps.InfoWindow();\n\t\t\t\t\t\t\tinfowindow.setContent('<div class=\"map_info_text\" style=\\'color:#000;\\'>" . trim(preg_replace('/\\s+/', ' ', do_shortcode($content))) . "</div>');";
                    if ($infowindow_open == 'off') {
                        $output .= "infowindow.open(map_{$id},marker_{$id});";
                    }
                    $output .= "google.maps.event.addListener(marker_{$id}, 'click', function() {\n\t\t\t\t\t\t\t\tinfowindow.open(map_{$id},marker_{$id});\n\t\t\t\t\t\t  \t});";
                }
            }
            $output .= "}\n\t\t\tcatch(e){};\n\t\t\tjQuery(document).ready(function(\$){\n\t\t\t\tgoogle.maps.event.trigger(map_{$id}, 'resize');\n\t\t\t\t\$(window).resize(function(){\n\t\t\t\t\tgoogle.maps.event.trigger(map_{$id}, 'resize');\n\t\t\t\t\tif(map_{$id}!=null)\n\t\t\t\t\t\tmap_{$id}.setCenter(coordinate_{$id});\n\t\t\t\t});\n\t\t\t\t\$('.ui-tabs').bind('tabsactivate', function(event, ui) {\n\t\t\t\t   if(\$(this).find('.ultimate-map-wrapper').length > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\t\t\$(window).trigger('resize');\n\t\t\t\t\t\t},200);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t\$('.ui-accordion').bind('accordionactivate', function(event, ui) {\n\t\t\t\t   if(\$(this).find('.ultimate-map-wrapper').length > 0)\n\t\t\t\t\t{\n\t\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\t\t\$(window).trigger('resize');\n\t\t\t\t\t\t},200);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t\$(window).load(function(){\n\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\t\$(window).trigger('resize');\n\t\t\t\t\t},200);\n\t\t\t\t});\n\t\t\t\t\$('.ult_exp_section').select(function(){\n\t\t\t\t\tif(\$(map_{$id}).parents('.ult_exp_section'))\n\t\t\t\t\t{\n\t\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\t\t\$(window).trigger('resize');\n\t\t\t\t\t\t},200);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t\$(document).on('onUVCModalPopupOpen', function(){\n\t\t\t\t\tif(\$(map_{$id}).parents('.ult_modal-content'))\n\t\t\t\t\t{\n\t\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\t\t\$(window).trigger('resize');\n\t\t\t\t\t\t},200);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\t\$(document).on('click','.ult_tab_li',function(){\n\t\t\t\t\t\$(window).trigger('resize');\n\t\t\t\t\tsetTimeout(function(){\n\t\t\t\t\t\t\$(window).trigger('resize');\n\t\t\t\t\t},200);\n\t\t\t\t});\n\t\t\t});\n\t\t\tfunction toggleBounce() {\n\t\t\t  if (marker_{$id}.getAnimation() != null) {\n\t\t\t\tmarker_{$id}.setAnimation(null);\n\t\t\t  } else {\n\t\t\t\tmarker_{$id}.setAnimation(google.maps.Animation.BOUNCE);\n\t\t\t  }\n\t\t\t}\n\t\t\t})(jQuery);\n\t\t\t</script>";
            return $output;
        }
 function run()
 {
     $session = CRM_Core_Session::singleton();
     $apiURL = "https://graph.facebook.com/v2.3";
     $redirect_uri = rawurldecode(CRM_Utils_System::url('civicrm/civisocial/facebookcallback', NULL, TRUE));
     // Retreive client_id and client_secret from settings
     $is_enabled = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'enable_facebook'));
     if (!$is_enabled) {
         die("Backend not enabled.");
     }
     $client_secret = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'facebook_secret'));
     $client_id = civicrm_api3('setting', 'getvalue', array('group' => 'CiviSocial Account Credentials', 'name' => 'facebook_app_id'));
     // Facebook sends a code to the callback url, this is further used to acquire
     // access token from facebook, which is needed to get all the data from facebook
     if (array_key_exists('code', $_GET)) {
         $facebook_code = $_GET['code'];
     } else {
         die("FACEBOOK FATAL: the request returned without the code. Please try loging in again.");
     }
     // Get the access token from facebook for the user
     $access_token = "";
     $access_token_response = $this->get_response($apiURL, "oauth/access_token", FALSE, array("client_id" => $client_id, "client_secret" => $client_secret, "code" => $facebook_code, "redirect_uri" => $redirect_uri));
     if (array_key_exists("error", $access_token_response)) {
         die($access_token_response["error"]);
         $access_token = "";
     } else {
         $access_token = $access_token_response["access_token"];
     }
     $user_data_response = $this->get_response($apiURL, "me", FALSE, array("access_token" => $access_token));
     $contact_id = CRM_Civisocial_BAO_CivisocialUser::handle_facebook_data($user_data_response);
     $this->assign('status', $contact_id);
     $session->set('userID', $contact_id);
     parent::run();
 }
示例#28
0
 public function match($pathinfo)
 {
     $allow = array();
     $pathinfo = rawurldecode($pathinfo);
     $context = $this->context;
     $request = $this->request;
     // homepage
     if (rtrim($pathinfo, '/') === '') {
         if (substr($pathinfo, -1) !== '/') {
             return $this->redirect($pathinfo . '/', 'homepage');
         }
         return array('_controller' => 'AppBundle\\Controller\\DefaultController::indexAction', '_route' => 'homepage');
     }
     if (0 === strpos($pathinfo, '/todos')) {
         // todo_list
         if ($pathinfo === '/todos') {
             return array('_controller' => 'AppBundle\\Controller\\TodoController::indexAction', '_route' => 'todo_list');
         }
         // todo_create
         if ($pathinfo === '/todos/create') {
             return array('_controller' => 'AppBundle\\Controller\\TodoController::createAction', '_route' => 'todo_create');
         }
         // todo_edit
         if (0 === strpos($pathinfo, '/todos/edit') && preg_match('#^/todos/edit/(?P<id>[^/]++)$#s', $pathinfo, $matches)) {
             return $this->mergeDefaults(array_replace($matches, array('_route' => 'todo_edit')), array('_controller' => 'AppBundle\\Controller\\TodoController::editAction'));
         }
         // todo_details
         if (0 === strpos($pathinfo, '/todos/details') && preg_match('#^/todos/details/(?P<id>[^/]++)$#s', $pathinfo, $matches)) {
             return $this->mergeDefaults(array_replace($matches, array('_route' => 'todo_details')), array('_controller' => 'AppBundle\\Controller\\TodoController::detailsAction'));
         }
     }
     throw 0 < count($allow) ? new MethodNotAllowedException(array_unique($allow)) : new ResourceNotFoundException();
 }
 /** {@inheritDoc} */
 public function getPath()
 {
     if (!($requestPath = $this->getServerVar("REQUEST_URI")) && !($requestPath = $this->getServerVar("ORIG_PATH_INFO"))) {
         $requestPath = $this->getIisRequestUri();
     }
     return "/" . trim(rawurldecode(strval(parse_url($requestPath, PHP_URL_PATH))), "/");
 }
示例#30
0
 public function __construct($settings)
 {
     $str = parse_url($settings);
     if (!$str) {
         throw new Exception('Malformed DB settings string: ' . $settings);
     }
     if (array_key_exists('scheme', $str)) {
         $this->type = rawurldecode($str['scheme']);
     }
     if (array_key_exists('user', $str)) {
         $this->username = rawurldecode($str['user']);
     }
     if (array_key_exists('pass', $str)) {
         $this->password = rawurldecode($str['pass']);
     }
     if (array_key_exists('path', $str)) {
         $this->database = trim(rawurldecode($str['path']), '/');
     }
     if (array_key_exists('host', $str)) {
         $this->servername = rawurldecode($str['host']);
     }
     if (array_key_exists('port', $str)) {
         $this->serverport = rawurldecode($str['port']);
     }
     if (array_key_exists('query', $str)) {
         parse_str($str['query'], $str);
         $this->persist = array_key_exists('persist', $str) && $str['persist'] === 'TRUE';
         if (array_key_exists('charset', $str)) {
             $this->charset = $str['charset'];
         }
         if (array_key_exists('timezone', $str)) {
             $this->timezone = $str['timezone'];
         }
     }
 }