/** * @param mixed $in */ public function __construct($in = null) { $fields = array('to', 'cc', 'bcc', 'message', 'body', 'subject'); if (is_string($in)) { if (($pos = strpos($in, '?')) !== false) { parse_str(substr($in, $pos + 1), $this->args); $this->args['to'] = substr($in, 0, $pos); } else { $this->args['to'] = $in; } } elseif ($in instanceof Horde_Variables) { foreach ($fields as $val) { if (isset($in->{$val})) { $this->args[$val] = $in->{$val}; } } } elseif (is_array($in)) { $this->args = $in; } if (isset($this->args['to']) && strpos($this->args['to'], 'mailto:') === 0) { $mailto = @parse_url($this->args['to']); if (is_array($mailto)) { $this->args['to'] = isset($mailto['path']) ? $mailto['path'] : ''; if (!empty($mailto['query'])) { parse_str($mailto['query'], $vals); foreach ($fields as $val) { if (isset($vals[$val])) { $this->args[$val] = $vals[$val]; } } } } } }
protected function _configureViaDSN($dsn) { $dsnVars = array(); if (strpos($dsn, '=') === false) { throw new Zend_Tool_Project_Provider_Exception('At least one name value pair is expected, typcially ' . 'in the format of "adapter=Mysqli&username=uname&password=mypass&dbname=mydb"'); } parse_str($dsn, $dsnVars); // parse_str suffers when magic_quotes is enabled if (get_magic_quotes_gpc()) { array_walk_recursive($dsnVars, array($this, '_cleanMagicQuotesInValues')); } $dbConfigValues = array('resources' => array('db' => null)); if (isset($dsnVars['adapter'])) { $dbConfigValues['resources']['db']['adapter'] = $dsnVars['adapter']; unset($dsnVars['adapter']); } $dbConfigValues['resources']['db']['params'] = $dsnVars; $isPretend = $this->_registry->getRequest()->isPretend(); // get the config resource $applicationConfig = $this->_loadedProfile->search('ApplicationConfigFile'); $applicationConfig->addItem($dbConfigValues, $this->_sectionName, null); $response = $this->_registry->getResponse(); if ($isPretend) { $response->appendContent('A db configuration for the ' . $this->_sectionName . ' section would be written to the application config file with the following contents: '); $response->appendContent($applicationConfig->getContents()); } else { $applicationConfig->create(); $response->appendContent('A db configuration for the ' . $this->_sectionName . ' section has been written to the application config file.'); } }
public function testRevokeAccess() { $accessToken = "ACCESS_TOKEN"; $refreshToken = "REFRESH_TOKEN"; $accessToken2 = "ACCESS_TOKEN_2"; $token = ""; $client = $this->getClient(); $response = $this->getMock("Google_Http_Request", array(), array('')); $response->expects($this->any())->method('getResponseHttpCode')->will($this->returnValue(200)); $io = $this->getMock("Google_IO_Stream", array(), array($client)); $io->expects($this->any())->method('makeRequest')->will($this->returnCallback(function ($request) use(&$token, $response) { $elements = array(); parse_str($request->getPostBody(), $elements); $token = isset($elements['token']) ? $elements['token'] : null; return $response; })); $client->setIo($io); // Test with access token. $oauth = new Google_Auth_OAuth2($client); $oauth->setAccessToken(json_encode(array('access_token' => $accessToken, 'created' => time(), 'expires_in' => '3600'))); $this->assertTrue($oauth->revokeToken()); $this->assertEquals($accessToken, $token); // Test with refresh token. $oauth = new Google_Auth_OAuth2($client); $oauth->setAccessToken(json_encode(array('access_token' => $accessToken, 'refresh_token' => $refreshToken, 'created' => time(), 'expires_in' => '3600'))); $this->assertTrue($oauth->revokeToken()); $this->assertEquals($refreshToken, $token); // Test with passed in token. $this->assertTrue($oauth->revokeToken($accessToken2)); $this->assertEquals($accessToken2, $token); }
/** * @inheritdoc * * @param array $arguments */ public function process_call($arguments) { $am = $this->get_am(); $am->ajax_begin(array('nonce' => $am->get_action_js_name(Types_Ajax::CALLBACK_SETTINGS_ACTION))); $setting = sanitize_text_field(wpcf_getpost('setting')); $setting_value = wpcf_getpost('setting_value'); if (!is_array($setting_value)) { parse_str($setting_value, $setting_value); $setting_value = array_pop($setting_value); } $sanitized_value = array(); foreach ($setting_value as $key => $value) { $sanitized_key = sanitize_title($key); $sanitized_value[$sanitized_key] = sanitize_text_field($value); } // use toolset settings if available if (class_exists('Toolset_Settings') && method_exists('Toolset_Settings', 'get_instance')) { $toolset_settings = Toolset_Settings::get_instance(); if (method_exists($toolset_settings, 'save')) { $toolset_settings[$setting] = $sanitized_value; $toolset_settings->save(); $am->ajax_finish('success', true); } } else { update_option($setting, $sanitized_value); $am->ajax_finish('success', true); } // default toolset setting error will be used // todo throw specific error $am->ajax_finish(array('error'), false); }
public function prepareExtract() { $request_uri = isset($_GET['REQUEST_URI']) ? $_GET['REQUEST_URI'] : (isset($_POST['REQUEST_URI']) ? $_POST['REQUEST_URI'] : (isset($_ENV['REQUEST_URI']) ? $_ENV['REQUEST_URI'] : getenv("REQUEST_URI"))); if (substr($request_uri, 0, 1) != "/") { $request_uri = "/" . $request_uri; } $request_uri = trim($request_uri); $url = "http" . (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? "s" : "") . "://" . getenv("HTTP_HOST") . $request_uri; // parse entire url $parsed_url = @parse_url($url); // validate query parameter if (is_array($parsed_url) && array_key_exists('query', $parsed_url) && $parsed_url['query']) { $parsed_query_arr = null; parse_str($parsed_url['query'], $parsed_query_arr); $_GET = $parsed_query_arr ? $parsed_query_arr : array(); } // superglobal arrays $superglobals = array("_COOKIE" => $_COOKIE, "_GET" => $_GET, "_POST" => $_POST, "_FILES" => $_FILES, "_ENV" => $_ENV, "_SERVER" => $_SERVER); // set default // merge superglobals arrays foreach ($superglobals as $key => $super_array) { // set internal data from superglobal arrays $this->{$key} = self::prepareSuperglobal($super_array); } return false; }
/** * Parse the incoming request in a RESTful way * * @param \PASL\Web\Service\Request The request object */ public function parseRequest($oRequest) { $oRequestData = array(); switch ($_SERVER['REQUEST_METHOD']) { case 'GET': $oRequestHash = $_REQUEST; break; case 'POST': $oRequestHash = $_REQUEST; break; case 'PUT': parse_str(file_get_contents("php://input"), $oRequestHash); break; } foreach ($oRequestHash as $val) { if (trim($val) != "" && !is_null($val)) { array_push($oRequest->oRequestHash, $val); } } $oRequest->requestPayload = $oRequestData; $oRequest->method = $oRequest->oRequestHash[2]; // Grab the method arguments $methodArgs = $oRequest->oRequestHash; array_shift($methodArgs); array_shift($methodArgs); array_shift($methodArgs); $oRequest->methodArgs = $methodArgs; return $oRequest; }
/** * @param array $vars An associative array with the following optional values: * @param array 'urlParams' the parameters which were matched from the URL * @param array 'get' the $_GET array * @param array|string 'post' the $_POST array or JSON string * @param array 'files' the $_FILES array * @param array 'server' the $_SERVER array * @param array 'env' the $_ENV array * @param array 'cookies' the $_COOKIE array * @param string 'method' the request method (GET, POST etc) * @param string|false 'requesttoken' the requesttoken or false when not available * @see http://www.php.net/manual/en/reserved.variables.php */ public function __construct(array $vars = array(), $stream = 'php://input') { $this->inputStream = $stream; $this->items['params'] = array(); if (!array_key_exists('method', $vars)) { $vars['method'] = 'GET'; } foreach ($this->allowedKeys as $name) { $this->items[$name] = isset($vars[$name]) ? $vars[$name] : array(); } // 'application/json' must be decoded manually. if (strpos($this->getHeader('Content-Type'), 'application/json') !== false) { $params = json_decode(file_get_contents($this->inputStream), true); if (count($params) > 0) { $this->items['params'] = $params; if ($vars['method'] === 'POST') { $this->items['post'] = $params; } } // Handle application/x-www-form-urlencoded for methods other than GET // or post correctly } elseif ($vars['method'] !== 'GET' && $vars['method'] !== 'POST' && strpos($this->getHeader('Content-Type'), 'application/x-www-form-urlencoded') !== false) { parse_str(file_get_contents($this->inputStream), $params); if (is_array($params)) { $this->items['params'] = $params; } } $this->items['parameters'] = array_merge($this->items['get'], $this->items['post'], $this->items['urlParams'], $this->items['params']); }
public function finalStep(&$state) { SimpleSAML_Logger::debug("oauth wrap: Using this verification code [" . $state['authwindowslive:wrap_verification_code'] . "]"); // Retrieve Access Token // Documentation at: http://msdn.microsoft.com/en-us/library/ff749686.aspx $postData = 'wrap_client_id=' . urlencode($this->key) . '&wrap_client_secret=' . urlencode($this->secret) . '&wrap_callback=' . urlencode(SimpleSAML_Module::getModuleUrl('authwindowslive') . '/linkback.php') . '&wrap_verification_code=' . urlencode($state['authwindowslive:wrap_verification_code']); $context = array('http' => array('method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postData)); $result = \SimpleSAML\Utils\HTTP::fetch('https://consent.live.com/AccessToken.aspx', $context); parse_str($result, $response); // error checking of $response to make sure we can proceed if (!array_key_exists('wrap_access_token', $response)) { throw new Exception('[' . $response['error_code'] . '] ' . $response['wrap_error_reason'] . "\r\nNo wrap_access_token returned - cannot proceed\r\n" . $response['internal_info']); } SimpleSAML_Logger::debug("Got an access token from the OAuth WRAP service provider [" . $response['wrap_access_token'] . "] for user [" . $response['uid'] . "]"); // Documentation at: http://msdn.microsoft.com/en-us/library/ff751708.aspx $opts = array('http' => array('header' => "Accept: application/json\r\nAuthorization: WRAP access_token=" . $response['wrap_access_token'] . "\r\n")); $data = \SimpleSAML\Utils\HTTP::fetch('https://apis.live.net/V4.1/cid-' . $response['uid'] . '/Profiles', $opts); $userdata = json_decode($data, TRUE); $attributes = array(); $attributes['windowslive_uid'] = array($response['uid']); $attributes['windowslive_targetedID'] = array('http://windowslive.com!' . $response['uid']); $attributes['windowslive_user'] = array($response['uid'] . '@windowslive.com'); if (array_key_exists('Entries', $userdata)) { foreach ($userdata['Entries'][0] as $key => $value) { if (is_string($value)) { $attributes['windowslive.' . $key] = array((string) $value); } } if (array_key_exists('Emails', $userdata['Entries'][0])) { $attributes['windowslive_mail'] = array($userdata['Entries'][0]['Emails'][0]['Address']); } } SimpleSAML_Logger::debug('LiveID Returned Attributes: ' . implode(", ", array_keys($attributes))); $state['Attributes'] = $attributes; }
/** * Resolve content meta data. * * @param array $content Original user provided content data * @return array $content Content data with additionaly retrieved meta data * @author Niklas Lindblad */ public function resolve($content) { /** * Video ID is given by the 'v' URL parameter. * * @author Niklas Lindblad */ parse_str(parse_url($content['url'], PHP_URL_QUERY), $output); $query = sprintf('http://gdata.youtube.com/feeds/api/videos?q=%s&max-results=1&v=2&alt=jsonc', $output['v']); $data = @json_decode(@file_get_contents($query), true); if (!$data) { throw new Exception('Could not retrieve meta data.'); } /** * Since we search for a unique ID, the first * result is always the one we want. * * @author Niklas Lindblad */ $data = $data['data']['items'][0]; $content['service'] = 'youtube'; $content['type'] = 'video'; $content['title'] = $data['title']; $content['length'] = $data['duration']; $content['video_id'] = $data['id']; $content['description'] = $data['description']; $content['thumbnail'] = $data['thumbnail']['hqDefault']; return $content; }
/** * Filter the arguments for HTTP requests. If the request is to a URL that's part of * something we're handling then filter the arguments accordingly. * * @author John Blackbourn * @param array $args HTTP request arguments. * @param string $url HTTP request URL. * @return array Updated array of arguments. */ public function filter_http_request_args(array $args, $url) { if (preg_match('#://api\\.wordpress\\.org/(?P<type>plugins|themes)/update-check/(?P<version>[0-9\\.]+)/#', $url, $matches)) { switch ($matches['type']) { case 'plugins': return $this->plugin_request($args, floatval($matches['version'])); break; case 'themes': return $this->theme_request($args, floatval($matches['version'])); break; } } $query = parse_url($url, PHP_URL_QUERY); if (empty($query)) { return $args; } parse_str($query, $query); if (!isset($query['_euapi_type']) or !isset($query['_euapi_file'])) { return $args; } if (!($handler = $this->get_handler($query['_euapi_type'], $query['_euapi_file']))) { return $args; } $args = array_merge($args, $handler->config['http']); return $args; }
/** * Constructor */ public function __construct() { $this->settings = get_option('woocommerce_amazon_payments_advanced_settings'); if (empty($this->settings['cart_button_display_mode'])) { $this->settings['cart_button_display_mode'] = 'button'; } if (empty($this->settings['seller_id'])) { $this->settings['seller_id'] = ''; } if (empty($this->settings['sandbox'])) { $this->settings['sandbox'] = 'yes'; } if (empty($this->settings['enabled'])) { $this->settings['enabled'] = 'no'; } if (empty($this->settings['hide_standard_checkout_button'])) { $this->settings['hide_standard_checkout_button'] = 'no'; } $this->reference_id = !empty($_REQUEST['amazon_reference_id']) ? $_REQUEST['amazon_reference_id'] : ''; if (isset($_POST['post_data'])) { parse_str($_POST['post_data'], $post_data); if (isset($post_data['amazon_reference_id'])) { $this->reference_id = $post_data['amazon_reference_id']; } } add_filter('plugin_action_links_' . plugin_basename(__FILE__), array($this, 'plugin_links')); add_action('init', array($this, 'init_gateway')); add_action('wp_loaded', array($this, 'init_handlers'), 11); add_action('wp_footer', array($this, 'maybe_hide_standard_checkout_button')); }
/** * Loads the entire menu table into memory. * * @return boolean True on success, false on failure * * @since 1.5 */ public function load() { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select('m.id, m.menutype, m.title, m.alias, m.note, m.path AS route, m.link, m.type, m.level, m.language')->select($db->quoteName('m.browserNav') . ', m.access, m.params, m.home, m.img, m.template_style_id, m.component_id, m.parent_id')->select('e.element as component')->from('#__menu AS m')->join('LEFT', '#__extensions AS e ON m.component_id = e.extension_id')->where('m.published = 1')->where('m.parent_id > 0')->where('m.client_id = 0')->order('m.lft'); // Set the query $db->setQuery($query); try { $this->_items = $db->loadObjectList('id'); } catch (RuntimeException $e) { JError::raiseWarning(500, JText::sprintf('JERROR_LOADING_MENUS', $e->getMessage())); return false; } foreach ($this->_items as &$item) { // Get parent information. $parent_tree = array(); if (isset($this->_items[$item->parent_id])) { $parent_tree = $this->_items[$item->parent_id]->tree; } // Create tree. $parent_tree[] = $item->id; $item->tree = $parent_tree; // Create the query array. $url = str_replace('index.php?', '', $item->link); $url = str_replace('&', '&', $url); parse_str($url, $item->query); } return true; }
public function submit($params, $radio) { //教务网登录 $this->login(); //获取评教参数 try { $http = new Http(array(CURLOPT_URL => $this->baseUrl . 'jxpjgl.do?' . $params, CURLOPT_COOKIE => $this->cookies, CURLOPT_TIMEOUT => 3)); } catch (\Exception $e) { throw new \Exception('网络异常,评教参数获取失败', Config::RETURN_ERROR); } $pattern = '/radioXh="0" value="(.*?)">(?:.*?)radioXh="1" value="(.*?)">(?:.*?)radioXh="2" value="(.*?)">(?:.*?)radioXh="3" value="(.*?)">/s'; preg_match_all($pattern, $http->content, $temp); if (count($temp[0]) != 10) { throw new \Exception('评教失败,请教参数有误', Config::RETURN_ERROR); } $mark = array($temp[1], $temp[2], $temp[3], $temp[4]); //构造get与post参数 $get = 'method=savePj&tjfs=2&val='; for ($i = 0; $i < 10; $i++) { $get .= urlencode($mark[$radio[$i]][$i]) . ($i == 9 ? '' : '*'); } parse_str($params, $temp); try { $http = new Http(array(CURLOPT_URL => $this->baseUrl . 'jxpjgl.do?' . $get, CURLOPT_POSTFIELDS => "type=2&pj09id=&pjdw=3&xsflid=&typejsxs=xs&pjfl=&pj01id={$temp['pj01id']}&pj05id={$temp['pj05id']}&jg0101id={$temp['jg0101id']}&jx0404id={$temp['jx0404id']}&pj0502id={$temp['pj0502id']}&jx02id={$temp['jx02id']}", CURLOPT_COOKIE => $this->cookies, CURLOPT_TIMEOUT => 3)); } catch (\Exception $e) { throw new \Exception('网络异常,评教提交失败', Config::RETURN_ERROR); } if (false === stripos($http->content, '提交成功!')) { throw new \Exception('未知错误,评教提交失败', Config::RETURN_ERROR); } return true; }
public function getDateRange() { $filter = $this->getParam($this->getVarNameFilter(), null); if (is_null($filter)) { $filter = $this->_defaultFilter; } $data = array(); if (is_string($filter)) { $filter = base64_decode($filter); parse_str(urldecode($filter), $data); $filter = $data; } if ($filter) { if (isset($filter['report_from'])) { $data['report_from'] = Mage::app()->getLocale()->date($filter['report_from'], Mage::app()->getLocale()->getDateFormat('short'), null, false); } if (isset($filter['report_to'])) { $data['report_to'] = Mage::app()->getLocale()->date($filter['report_to'], Mage::app()->getLocale()->getDateFormat('short'), null, false); } } else { $data = $this->_defaultFilters; } if (!isset($data['report_from'])) { // getting all reports from 2001 year $data['report_from'] = new Zend_Date(mktime(0, 0, 0, 1, 1, 2001)); } if (!isset($data['report_to'])) { $data['report_to'] = new Zend_Date(); $data['report_to']->addDay(1); // tomorrow at 0am; otherwise today's donations will not be displayed } //var_dump("{$data['report_from']} {$data['report_to']}"); return $data; }
/** * Parses an URI string returning an array of connection parameters. * * When using the "redis" and "rediss" schemes the URI is parsed according * to the rules defined by the provisional registration documents approved * by IANA. If the URI has a password in its "user-information" part or a * database number in the "path" part these values override the values of * "password" and "database" if they are present in the "query" part. * * @link http://www.iana.org/assignments/uri-schemes/prov/redis * @link http://www.iana.org/assignments/uri-schemes/prov/redis * * @param string $uri URI string. * * @throws \InvalidArgumentException * * @return array */ public static function parse($uri) { if (stripos($uri, 'unix') === 0) { // Hack to support URIs for UNIX sockets with minimal effort. $uri = str_ireplace('unix:///', 'unix://localhost/', $uri); } if (!($parsed = parse_url($uri))) { throw new \InvalidArgumentException("Invalid parameters URI: {$uri}"); } if (isset($parsed['host']) && false !== strpos($parsed['host'], '[') && false !== strpos($parsed['host'], ']')) { $parsed['host'] = substr($parsed['host'], 1, -1); } if (isset($parsed['query'])) { parse_str($parsed['query'], $queryarray); unset($parsed['query']); $parsed = array_merge($parsed, $queryarray); } if (stripos($uri, 'redis') === 0) { if (isset($parsed['pass'])) { $parsed['password'] = $parsed['pass']; unset($parsed['pass']); } if (isset($parsed['path']) && preg_match('/^\\/(\\d+)(\\/.*)?/', $parsed['path'], $path)) { $parsed['database'] = $path[1]; if (isset($path[2])) { $parsed['path'] = $path[2]; } else { unset($parsed['path']); } } } return $parsed; }
/** * Verifying required params posted or not */ function verifyRequiredParams($required_fields) { $error = false; $error_fields = ""; $request_params = array(); $request_params = $_REQUEST; // Handling PUT request params if ($_SERVER['REQUEST_METHOD'] == 'PUT') { $app = \Slim\Slim::getInstance(); parse_str($app->request()->getBody(), $request_params); } foreach ($required_fields as $field) { if (!isset($request_params[$field]) || strlen(trim($request_params[$field])) <= 0) { $error = true; $error_fields .= $field . ', '; } } if ($error) { // Required field(s) are missing or empty // echo error json and stop the app $response = array(); $app = \Slim\Slim::getInstance(); $response["error"] = true; $response["message"] = 'Required field(s) ' . substr($error_fields, 0, -2) . ' is missing or empty'; echoResponse(400, $response); $app->stop(); } }
public function httpPutUpdate(Com_Icodeecono_Api_ApiResponder &$responder, array $passedParams = null) { $responder->setResponseStatus(Com_Icodeecono_Api_ApiResponseStatuses::STATUS_200_OK); $put_vars = array(); parse_str(file_get_contents('php://input'), $put_vars); $responder->setRawReturnData($put_vars); }
public function qq_callback() { $state = $this->recorder->read("state"); //--------验证state防止CSRF攻击 if ($_GET['state'] != $state) { $this->error->showError("30001"); } //-------请求参数列表 $keysArr = array("grant_type" => "authorization_code", "client_id" => $this->recorder->readInc("appid"), "redirect_uri" => urlencode($this->recorder->readInc("callback")), "client_secret" => $this->recorder->readInc("appkey"), "code" => $_GET['code']); //------构造请求access_token的url $token_url = $this->urlUtils->combineURL(self::GET_ACCESS_TOKEN_URL, $keysArr); $response = $this->urlUtils->get_contents($token_url); if (strpos($response, "callback") !== false) { $lpos = strpos($response, "("); $rpos = strrpos($response, ")"); $response = substr($response, $lpos + 1, $rpos - $lpos - 1); $msg = json_decode($response); if (isset($msg->error)) { $this->error->showError($msg->error, $msg->error_description); } } $params = array(); parse_str($response, $params); $this->recorder->write("access_token", $params["access_token"]); return $params["access_token"]; }
function run_transaction($vars) { foreach ($vars as $kk => $vv) { $v = urlencode($vv); $k = urlencode($kk); $vars1[] = "{$k}={$v}"; } $vars1 = join('&', $vars1); $ret = cc_core_get_url("https://4tknox.au.com/cgi-bin/themerchant.au.com/ecom/external2.pl", $vars1); $delim = "\n"; $arr = preg_split("({$delim})", $ret); $res["RESULT_CODE"] = strtolower($arr[0]); if (@strpos($ret, "{$delim}.{$delim}") === false) { $res["RESPONSE_TEXT"] = $arr[1]; } else { $ret = substr($ret, @strpos($ret, "{$delim}.{$delim}")); $ret = str_replace($delim, "&", $ret); parse_str($ret, $ret); $res["RESPONSE_TEXT"] = $ret["response_text"]; $res["TXN_REF"] = $ret["txn_ref"]; $res["RESPONSE_CODE"] = $ret["response_code"]; $res["RESULT"] = $ret["result"]; } //var_dump($res); return $res; }
public function __construct() { parent::__construct(); parse_str($_SERVER['QUERY_STRING'], $_REQUEST); $this->load->library('facebook', array("appId" => '361675743907292', "secret" => '65346749b5c11d2842b322bcc99f247e')); $this->user = $this->facebook->getUser(); }
private function clean_content() { $parameters = array(); $content = file_get_contents("php://input"); $format = "html"; switch ($this->ctype) { case "application/json": $params = json_decode($content); if ($params) { foreach ($params as $param_name => $param_value) { $parameters[$param_name] = $param_value; } } $format = "json"; break; case "application/x-www-form-urlencoded": parse_str($content, $postvars); foreach ($postvars as $field => $value) { $parameters[$field] = $value; } $format = "html"; break; default: break; } $this->contents = (object) array('content' => $content, 'parameters' => $parameters, 'format' => $format); }
public function run($group_id = false) { if (!$this->request->isAjax()) { cmsCore::error404(); } $grid = $this->loadDataGrid('users'); $users_model = cmsCore::getModel('users'); $users_model->setPerPage(admin::perpage); $filter = array(); $filter_str = $this->request->get('filter'); $filter_str = cmsUser::getUPSActual('admin.grid_filter.users', $filter_str); if ($filter_str) { $content_model = cmsCore::getModel('content')->setTablePrefix(''); parse_str($filter_str, $filter); $users_model->applyGridFilter($grid, $filter); if (!empty($filter['advanced_filter'])) { parse_str($filter['advanced_filter'], $dataset_filters); $users_model->applyDatasetFilters($dataset_filters); } } if ($group_id) { $users_model->filterGroup($group_id); } $total = $users_model->getUsersCount(); $perpage = isset($filter['perpage']) ? $filter['perpage'] : admin::perpage; $pages = ceil($total / $perpage); $users = $users_model->getUsers(); cmsTemplate::getInstance()->renderGridRowsJSON($grid, $users, $total, $pages); $this->halt(); }
function payza_refund($params) { if ($params['testmode'] == "on") { $url = "https://sandbox.Payza.com/api/api.svc/RefundTransaction"; } else { $url = "https://api.payza.com/svc/api.svc/RefundTransaction"; } $username = $params['email']; $password = $params['apipassword']; $testmode = $params['testmode'] ? "1" : "0"; $results = ""; $postdata = "USER="******"&PASSWORD="******"&TRANSACTIONREFERENCE=" . urlencode($params['transid']) . "&AMOUNT=" . urlencode($params['amount']) . "&TESTMODE=" . $testmode; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); $data = curl_exec($ch); curl_close($ch); parse_str($data, $results); if ($results['RETURNCODE'] == "100") { return array("status" => "success", "transid" => $results['REFERENCENUMBER'], "rawdata" => $results); } return array("status" => "failed", "rawdata" => $results); }
/** * Process the current request * * $request - The current request parameters. Leave as NULL to default to use $_REQUEST. */ public static function process($request = NULL) { // Setup request variable Hybrid_Endpoint::$request = $request; if (is_null(Hybrid_Endpoint::$request)) { // Fix a strange behavior when some provider call back ha endpoint // with /index.php?hauth.done={provider}?{args}... // >here we need to recreate the $_REQUEST if (strrpos($_SERVER["QUERY_STRING"], '?')) { $_SERVER["QUERY_STRING"] = str_replace("?", "&", $_SERVER["QUERY_STRING"]); parse_str($_SERVER["QUERY_STRING"], $_REQUEST); } Hybrid_Endpoint::$request = $_REQUEST; } // If windows_live_channel requested, we return our windows_live WRAP_CHANNEL_URL if (isset(Hybrid_Endpoint::$request["get"]) && Hybrid_Endpoint::$request["get"] == "windows_live_channel") { Hybrid_Endpoint::processWindowsLiveChannel(); } // If openid_policy requested, we return our policy document if (isset(Hybrid_Endpoint::$request["get"]) && Hybrid_Endpoint::$request["get"] == "openid_policy") { Hybrid_Endpoint::processOpenidPolicy(); } // If openid_xrds requested, we return our XRDS document if (isset(Hybrid_Endpoint::$request["get"]) && Hybrid_Endpoint::$request["get"] == "openid_xrds") { Hybrid_Endpoint::processOpenidXRDS(); } // If we get a hauth.start if (isset(Hybrid_Endpoint::$request["hauth_start"]) && Hybrid_Endpoint::$request["hauth_start"]) { Hybrid_Endpoint::processAuthStart(); } elseif (isset(Hybrid_Endpoint::$request["hauth_done"]) && Hybrid_Endpoint::$request["hauth_done"]) { Hybrid_Endpoint::processAuthDone(); } else { Hybrid_Endpoint::processOpenidRealm(); } }
/** * Cookie 设置、获取、删除 * * @param string $name cookie名称 * @param mixed $value cookie值 * @param mixed $option 可选参数 可能会是 null|integer|string * * @return mixed * @internal param mixed $options cookie参数 */ public static function set($name, $value = '', $option = null) { !isset(self::$init) && self::init(); // 参数设置(会覆盖黙认设置) if (!is_null($option)) { if (is_numeric($option)) { $option = ['expire' => $option]; } elseif (is_string($option)) { parse_str($option, $option); } $config = array_merge(self::$config, array_change_key_case($option)); } else { $config = self::$config; } $name = $config['prefix'] . $name; // 设置cookie if (is_array($value)) { array_walk_recursive($value, 'self::jsonFormatProtect', 'encode'); $value = 'think:' . json_encode($value); } $expire = !empty($config['expire']) ? $_SERVER['REQUEST_TIME'] + intval($config['expire']) : 0; if ($config['setcookie']) { setcookie($name, $value, $expire, $config['path'], $config['domain'], $config['secure'], $config['httponly']); } $_COOKIE[$name] = $value; }
public static function parse_settings($editor_id, $settings) { $set = wp_parse_args($settings, array('wpautop' => true, 'media_buttons' => true, 'textarea_name' => $editor_id, 'textarea_rows' => 20, 'tabindex' => '', 'tabfocus_elements' => ':prev,:next', 'editor_css' => '', 'editor_class' => '', 'teeny' => false, 'dfw' => false, 'tinymce' => true, 'quicktags' => true)); self::$this_tinymce = $set['tinymce'] && user_can_richedit(); self::$this_quicktags = (bool) $set['quicktags']; if (self::$this_tinymce) { self::$has_tinymce = true; } if (self::$this_quicktags) { self::$has_quicktags = true; } if (empty($set['editor_height'])) { return $set; } if ('content' === $editor_id) { // A cookie (set when a user resizes the editor) overrides the height. $cookie = (int) get_user_setting('ed_size'); // Upgrade an old TinyMCE cookie if it is still around, and the new one isn't. if (!$cookie && isset($_COOKIE['TinyMCE_content_size'])) { parse_str($_COOKIE['TinyMCE_content_size'], $cookie); $cookie = $cookie['ch']; } if ($cookie) { $set['editor_height'] = $cookie; } } if ($set['editor_height'] < 50) { $set['editor_height'] = 50; } elseif ($set['editor_height'] > 5000) { $set['editor_height'] = 5000; } return $set; }
/** @param $a the token passed back from the oAuth Provider, typically $_GET['oauth_token'] */ public function getAccessToken($tok) { $uri = self::ACCESS_TOKEN_URI; $arg = array('oauth_token' => $tok['oauth_token'], 'oauth_consumer_key' => $this->_oauth_client_id, 'oauth_signature_method' => 'PLAINTEXT', 'oauth_signature' => '&' . $tok['oauth_token_secret']); // radix::dump($uri); // radix::dump($arg); $res = radix_http::post($uri, $arg); // radix::dump($res); parse_str($res['body'], $x); return $x; // radix::dump($x); // exit; // $arg = array( // 'client_id' => $this->_oauth_client_id, // 'client_secret' => $this->_oauth_client_secret, // 'grant_type' => 'authorization_code', // 'redirect_uri' => $a['redirect_uri'], // 'code' => $a['code'], // ); // $res = radix_http::get($uri . '?' . http_build_query($arg)); // radix::dump($res); // $ret = json_decode($res['body'],true); try { $res = $this->_oauth->getAccessToken($uri); $this->_oauth->setToken($res['oauth_token'], $res['oauth_token_secret']); // radix::dump($res); // exit; return $res; } catch (Exception $e) { radix::dump($this->_oauth->debugInfo); return false; } return $ret; }
/** * Method to get the field options. * * @return array The field option objects. * * @since 11.1 */ protected function getOptions() { $options = array(); $options[] = JHtml::_('select.option', 'id', JText::_('COM_VISFORMS_ID'), 'value', 'text', false); $options[] = JHtml::_('select.option', 'created', JText::_('COM_VISFORMS_SUBMISSIONDATE'), 'value', 'text', false); $options[] = JHtml::_('select.option', 'ismfd', JText::_('COM_VISFORMS_MODIFIED'), 'value', 'text', false); $id = 0; //extract form id $form = $this->form; $link = $form->getValue('link'); if (isset($link) && $link != "") { $parts = array(); parse_str($link, $parts); if (isset($parts['id']) && is_numeric($parts['id'])) { $id = $parts['id']; } } // Create options according to visfield settings $db = JFactory::getDbo(); $query = ' SELECT c.id , c.label from #__visfields as c where c.fid=' . $id . ' AND c.published = 1 AND (c.frontdisplay is null or c.frontdisplay = 1 or c.frontdisplay = 2) ' . "and !(c.typefield = 'reset') and !(c.typefield = 'submit') and !(c.typefield = 'image') and !(c.typefield = 'fieldsep') and !(c.typefield = 'hidden')"; $db->setQuery($query); $fields = $db->loadObjectList(); if ($fields) { foreach ($fields as $field) { $tmp = JHtml::_('select.option', $field->id, $field->label, 'value', 'text', false); // Add the option object to the result set. $options[] = $tmp; } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
public function actionToken($state) { // only poeple on the list should be generating new tokens if (!$this->context->token->checkAccess($_SERVER['REMOTE_ADDR'])) { echo "Oh sorry man, this is a private party!"; mail($this->context->token->getEmail(), 'Notice', 'The token is maybe invalid!'); $this->terminate(); } // facebook example code... $stoken = $this->session->getSection('token'); if (!isset($_GET['code'])) { $stoken->state = md5(uniqid(rand(), TRUE)); //CSRF protection $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" . $this->context->token->getAppId() . "&redirect_uri=" . urlencode($this->link('//Crawler:token')) . "&scope=" . $this->context->token->getAppPermissions() . "&state=" . $stoken->state; echo "<script> top.location.href='" . $dialog_url . "'</script>"; $this->terminate(); } if (isset($stoken->state) && $stoken->state === $_GET['state']) { $token_url = "https://graph.facebook.com/oauth/access_token?" . "client_id=" . $this->context->token->getAppId() . "&redirect_uri=" . urlencode($this->link('//Crawler:token')) . "&client_secret=" . $this->context->token->getAppSecret() . "&code=" . $_GET['code']; $response = file_get_contents($token_url); $params = null; parse_str($response, $params); $date = new DateTime(); $date->add(new DateInterval('PT' . $params["expires"] . 'S')); $this->context->token->saveToken($params['access_token'], $date); echo "Thanks for your token :)"; } else { echo "The state does not match. You may be a victim of CSRF."; } $this->terminate(); }
/** * Make API request * * @param string $method string API method to request * @param array $params Additional request parameters * @return array / boolean Response array / boolean false on failure */ public function request($method, $params = array()) { $this->_errors = array(); if (empty($method)) { //Check if API method is not empty $this->_errors = array('API method is missing'); return false; } //Our request parameters $requestParams = array('METHOD' => $method, 'VERSION' => $this->_version) + $this->_credentials; //Building our NVP string $request = http_build_query($requestParams + $params); //cURL settings $curlOptions = array(CURLOPT_URL => $this->_endPoint, CURLOPT_VERBOSE => 1, CURLOPT_SSL_VERIFYPEER => true, CURLOPT_SSL_VERIFYHOST => 2, CURLOPT_CAINFO => dirname(__FILE__) . '/cacert.pem', CURLOPT_RETURNTRANSFER => 1, CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $request); $ch = curl_init(); curl_setopt_array($ch, $curlOptions); //Sending our request - $response will hold the API response $response = curl_exec($ch); //Checking for cURL errors if (curl_errno($ch)) { $this->_errors = curl_error($ch); curl_close($ch); return false; //Handle errors } else { curl_close($ch); $responseArray = array(); parse_str($response, $responseArray); // Break the NVP string to an array return $responseArray; } }