本文整理汇总了PHP中urlEncode函数的典型用法代码示例。如果您正苦于以下问题:PHP urlEncode函数的具体用法?PHP urlEncode怎么用?PHP urlEncode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了urlEncode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sms_send
function sms_send($phone, $content)
{
global $INI;
if (mb_strlen($content, 'UTF-8') < 20) {
return '短信长度低于20汉字?长点吧~';
}
/* include customsms function */
$smsowner_file = dirname(__FILE__) . '/smsowner.php';
if (file_exists($smsowner_file)) {
require_once $smsowner_file;
if (function_exists('sms_send_owner')) {
return sms_send_owner($phone, $content);
}
}
/* end include */
$user = strval($INI['sms']['user']);
$pass = strtolower(md5($INI['sms']['pass']));
if (null == $user) {
return true;
}
$content = urlEncode($content);
$api = "http://notice.zuitu.com/sms?user={$user}&pass={$pass}&phones={$phone}&content={$content}";
$res = Utility::HttpRequest($api);
return trim(strval($res)) == '+OK' ? true : strval($res);
}
示例2: getUserInfo
public function getUserInfo($accessToken)
{
// Get the correct Profile Endpoint URL based off the country/region provided in the config['region']
$this->profileEndpointUrl();
if (empty($accessToken)) {
throw new \InvalidArgumentException('Access Token is a required parameter and is not set');
}
// To make sure double encoding doesn't occur decode first and encode again.
$accessToken = urldecode($accessToken);
$url = $this->profileEndpoint . '/auth/o2/tokeninfo?access_token=' . urlEncode($accessToken);
$httpCurlRequest = new HttpCurl($this->config);
$response = $httpCurlRequest->httpGet($url);
$data = json_decode($response);
if ($data->aud != $this->config['client_id']) {
// The access token does not belong to us
throw new \Exception('The Access token entered is incorrect');
}
// Exchange the access token for user profile
$url = $this->profileEndpoint . '/user/profile';
$httpCurlRequest = new HttpCurl($this->config);
$httpCurlRequest->setAccessToken($accessToken);
$httpCurlRequest->setHttpHeader(true);
$response = $httpCurlRequest->httpGet($url);
$userInfo = json_decode($response, true);
return $userInfo;
}
示例3: cleanUrl
/**
* Cleans a URL so it's safe to print to the browser without issues.
* @param uri String The URL to parse
* @return String The clean URL to print
*/
public static function cleanUrl($uri)
{
$result = null;
$url = htmlEntities($uri, ENT_QUOTES, 'utf-8');
$parse = parse_url($url);
$result = "{$parse['scheme']}://";
$parse['path'] = ltrim($parse['path'], '/');
foreach (array('user', 'pass', 'path', 'query', 'fragment') as $p) {
if (isset($parse[$p])) {
$parse[$p] = urlEncode($parse[$p]);
}
}
if (!empty($parse['user'])) {
$result .= "{$parse['user']}";
if (empty($parse['pass'])) {
$result .= '@';
} else {
$result .= ":{$parse['pass']}@";
}
}
$result .= "{$parse['host']}/{$parse['path']}";
if (!empty($parse['query'])) {
$result .= "?{$parse['query']}";
}
if (!empty($parse['fragment'])) {
$result .= "#{$parse['fragment']}";
}
return $result;
}
示例4: genURL
private function genURL($url = "/", $param, $value)
{
if (false === strpos($url, '?')) {
return $url . '?' . urlEncode($param) . '=' . urlEncode($value);
} else {
return $url . '&' . urlEncode($param) . '=' . urlEncode($value);
}
}
示例5: showBody
function showBody()
{
#----------------------------------------------------------------------
global $chosenPersonId;
// simple validation first...
if (!preg_match('/\\d{4}\\w{4}\\d{2}/', $chosenPersonId)) {
showErrorMessage('Invalid WCA id Format <strong>[</strong>' . o($chosenPersonId) . '<strong>]</strong>');
print '<p><a href="persons.php">Click here to search for people.</a></p>';
return;
}
#--- Get all incarnations of the person.
$persons = dbQuery("\n SELECT person.name personName, country.name countryName, day, month, year, gender\n FROM Persons person, Countries country\n WHERE person.id = '{$chosenPersonId}' AND country.id = person.countryId\n ORDER BY person.subId\n ");
#--- If there are none, show an error and do no more.
if (!count($persons)) {
showErrorMessage('Unknown person id <strong>[</strong>' . o($chosenPersonId) . '<strong>]</strong>');
$namepart = substr($chosenPersonId, 4, 4);
print '<p><a href="persons.php?pattern=' . urlEncode($namepart) . '">Click to search for people with `' . o($namepart) . '` in their name.</a></p>';
return;
}
#--- Get and show the current incarnation.
$currentPerson = array_shift($persons);
extract($currentPerson);
echo "<h1>{$personName}</h1>";
#--- Show previous incarnations if any.
if (count($persons)) {
echo "<p class='subtitle'>(previously ";
foreach ($persons as $person) {
$previous[] = "{$person['personName']}/{$person['countryName']}";
}
echo implode(', ', $previous) . ")</p>";
}
#--- Show the picture if any.
$picture = getCurrentPictureFile($chosenPersonId);
if ($picture) {
echo "<center><img class='person' src='{$picture}' /></center>";
}
#--- Show the In Memoriam if any.
$inMemoriamArray = array("2008COUR01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=2028", "2003LARS01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=1982", "2012GALA02" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=1044", "2008LIMR01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=945", "2008KIRC01" => "https://www.worldcubeassociation.org/forum/viewtopic.php?t=470");
if (array_key_exists($chosenPersonId, $inMemoriamArray)) {
echo "<center><a target='_blank' href='{$inMemoriamArray[$chosenPersonId]}'>In Memoriam</a></center>";
}
#--- Show the details.
tableBegin('results', 4);
tableCaption(false, 'Details');
tableHeader(explode('|', 'Country|WCA Id|Gender|Competitions'), array(3 => 'class="f"'));
$gender_text = genderText($gender);
$numberOfCompetitions = dbValue("SELECT count(distinct competitionId) FROM Results where personId='{$chosenPersonId}'");
tableRow(array($countryName, $chosenPersonId, $gender_text, $numberOfCompetitions));
tableEnd();
#--- Try the cache for the results
# tryCache( 'person', $chosenPersonId );
#--- Now the results.
require 'includes/person_personal_records_current.php';
require 'includes/person_world_championship_podiums.php';
require 'includes/person_world_records_history.php';
require 'includes/person_continent_records_history.php';
require 'includes/person_events.php';
}
示例6: getListFileTree
public function getListFileTree($path = '', $jump = '')
{
$option = "com_xsltmagic";
$files = array();
$folders = array();
$size = 0;
foreach (scandir($path) as $v) {
if (!is_dir($path . '/' . $v)) {
$files[] = $path . '/' . $v;
continue;
}
if (substr($v, 0, 1) != '.') {
// not need '.' '..'
$folders[] = $path . '/' . $v;
}
}
natcasesort($folders);
natcasesort($files);
if (isset($jump)) {
$link = explode('&', $jump);
$url = '';
for ($i = 1; $i < count($link) - 1; $i++) {
$url .= '&' . $link[$i];
}
$row[$size]->link = JRoute::_("index.php?option={$option}&controller=xslts" . $url);
$row[$size]->checked_out = false;
$row[$size]->name = '...';
$size++;
}
// Folders
for ($f = 0; $f < count($folders); $f++) {
$currentFolder = str_replace($path . '/', '', $folders[$f]);
$link = $jump . '&jump[]=' . basename($currentFolder);
$row[$size]->link = JRoute::_("index.php?option={$option}&controller=xslts" . $link);
$row[$size]->checked_out = false;
$row[$size]->name = basename($currentFolder);
$row[$size]->type = 'Folder';
$row[$size]->modified = date("d.m.Y H:i:s", filemtime($path . DS . $currentFolder));
$size++;
}
// Process files
for ($h = 0; $h < count($files); $h++) {
$currentFile = str_replace($path . '/', '', $files[$h]);
$currentEncoded = urlEncode($currentFile);
$subArr = explode('%2F', $currentEncoded);
$filename = $subArr[count($subArr) - 1];
$subArrr = explode('.', $filename);
$extension = $subArrr[count($subArrr) - 1];
$row[$size]->link = JRoute::_("index.php?option={$option}&id[]={$filename}&task=edit&controller=xslts" . $jump);
$row[$size]->checked_out = false;
$row[$size]->name = $filename;
$row[$size]->type = $extension;
$row[$size]->modified = date("d.m.Y H:i:s", filemtime($path . DS . $currentFile));
$row[$size]->fileSize = round(filesize($path . DS . $currentFile) / 1024) . ' kb';
$size++;
}
return $row;
}
示例7: sms_send
function sms_send($phone, $content)
{
global $INI;
if (mb_strlen($content, 'UTF-8') < 20) {
return '短信长度低于20汉字?长点吧~';
}
$user = $INI['sms']['user'];
$pass = strtolower(md5($INI['sms']['pass']));
$content = urlEncode($content);
$api = "http://notice.zuitu.com/sms?user={$user}&pass={$pass}&phones={$phone}&content={$content}";
$res = Utility::HttpRequest($api);
return trim(strval($res)) == '+OK' ? true : strval($res);
}
示例8: sendAvicSMSAction
public function sendAvicSMSAction($mobiles, $msg)
{
$SMS_ACT = $this->container->getParameter('SMS_ACT');
$SMS_PWD = $this->container->getParameter('SMS_PWD');
$SMS_URL = $this->container->getParameter('SMS_URL');
$SMS_EID = $this->container->getParameter('SMS_EID');
$mobiles = str_replace(";", ",", $mobiles);
$content = urlEncode(urlEncode(mb_convert_encoding($msg, 'gb2312', 'utf-8')));
$pwd = md5($SMS_PWD);
$apidata = "username={$SMS_ACT}&password={$pwd}&message={$content}&phone={$mobiles}&epid={$SMS_EID}&linkid=&subcode=";
$this->get("logger")->err($SMS_URL . "?" . $apidata);
$result = mb_convert_encoding($this->do_post_request($SMS_URL . "?" . $apidata, null), 'utf-8', 'gb2312');
$this->get("logger")->err($result);
return Utils::WrapResultOK('');
}
示例9: exchangeRate
function exchangeRate($amount, $currency, $exchangeIn)
{
$url = @'http://www.google.com/ig/calculator?hl=en&q=' . urlEncode($amount . $currency . '=?' . $exchangeIn);
$data = @file_get_contents($url);
if (!$data) {
throw new Exception('Could not connect');
}
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
$array = $json->decode($data);
if (!$array) {
throw new Exception('Could not parse the JSON');
}
if ($array['error']) {
throw new Exception('Google reported an error: ' . $array['error']);
}
return (double) $array['rhs'];
}
示例10: choice
function choice($id, $caption, $options, $chosenOption)
{
#----------------------------------------------------------------------
$result = "<label for='{$id}'>";
$result .= $caption ? "{$caption}:<br />" : '';
$result .= "<select class='drop' id='{$id}' name='{$id}'>\n";
$chosen = urlEncode($chosenOption);
foreach ($options as $option) {
$nick = urlEncode($option[0]);
$text = htmlEntities($option[1], ENT_QUOTES, "UTF-8");
$selected = $chosen && $nick == $chosen ? " selected='selected'" : "";
$result .= "<option value='{$nick}'{$selected}>{$text}</option>\n";
}
$result .= "</select>";
$result .= "</label>";
return $result;
}
示例11: accesCle
function accesCle($tuple, $format = "url")
{
$separateur = $chaine = "";
// Parcours des attributs
foreach ($this->schemaTable as $nom => $options) {
// C'est un attribut de la cl� primaire
if ($options['cle_primaire']) {
if ($format == "url") {
$chaine .= "&{$nom}=" . urlEncode($tuple[$nom]);
$separateur = "&";
} else {
$chaine .= "{$separateur}{$nom}='" . addSlashes($tuple[$nom]) . "'";
$separateur = " AND ";
}
}
}
return $chaine;
}
示例12: Convert
/**
* Converts currency using google. throws an exception if something went wrong
*
* @param numeric $amount
* @param string from currency (ex USD)
* @param string to currency (ex EUR)
* @return number
* @author: http://www.it-base.ro/2007/07/09/currency-conversion-in-php
* @author: Jason M Hinkle
* @version: 1.0
*/
public static function Convert($amount, $from, $to)
{
$converted_amount = 0;
$qs = $amount . ' ' . $from . ' in ' . $to;
$url = "http://www.google.com/search?q=" . urlEncode($qs);
$g_response = strip_tags(HttpRequest::Get($url));
if (preg_match("/Rates provided for information only - see disclaimer./i", $g_response)) {
$matches = array();
preg_match('/= ([0-9\\s\\.,]+)/', $g_response, $matches);
if ($matches[1]) {
$converted_amount = $matches[1];
} else {
// this should never occur unless google changes the output formatting of the search results
throw new Exception("Unable to parse response from google");
}
} else {
throw new Exception("The google search result does not appear to contain currency information");
}
return $converted_amount;
}
示例13: send
public function send($mobile, $content, $schedule = null)
{
$providerInfo = $this->_getProviderInfo();
if ($schedule == "0000-00-00 00:00:00") {
$schedule = '';
} else {
$schedule = date('Y-m-d H:i:s', strtotime($schedule));
}
$sender = new BayouSmsSender();
$content_log = $content;
$content = urlEncode(urlEncode(mb_convert_encoding($content, 'gb2312', 'utf-8')));
$result = $sender->sendsms($providerInfo['username'], md5($providerInfo['password']), $mobile, $content, $schedule);
if ($result['status'] == 0) {
Openbiz::getService(LOG_SERVICE)->log(LOG_ERR, "SMS", "sendMessage: " . $content . " Bayou:" . $mobile . ':' . $result['msg']);
return false;
} else {
$this->HitMessageCounter();
$this->_log($mobile, $content_log, $schedule);
return true;
}
}
示例14: encodeValue
protected static function encodeValue($value)
{
return urlEncode($value);
}
示例15: _mac_addr_internal
$phone_types['polycom-spip-450'] = 'Polycom SoundPoint IP 450';
$phone_types['polycom-spip-501'] = 'Polycom SoundPoint IP 501';
$phone_types['polycom-spip-550'] = 'Polycom SoundPoint IP 550';
$phone_types['polycom-spip-560'] = 'Polycom SoundPoint IP 560';
$phone_types['polycom-spip-601'] = 'Polycom SoundPoint IP 601';
$phone_types['polycom-spip-650'] = 'Polycom SoundPoint IP 650';
$phone_types['polycom-spip-670'] = 'Polycom SoundPoint IP 670';
}
$per_page = (int) GS_GUI_NUM_RESULTS;
$mac_addr_internal = _mac_addr_internal(@$_REQUEST['mac']);
$mac_addr_display = _mac_addr_display($mac_addr_internal);
$pbx_id = array_key_exists('pbx_id', $_REQUEST) ? (int) $_REQUEST['pbx_id'] : -1;
$ip_addr = trim(@$_REQUEST['ip']);
$phone_type = @$_REQUEST['phone_type'];
$page = (int) @$_REQUEST['page'];
$search_url = 'mac=' . urlEncode($mac_addr_internal) . '&' . 'ip=' . urlEncode($ip_addr) . '&' . 'pbx_id=' . urlEncode($pbx_id) . '&' . 'phone_type=' . urlEncode($phone_type);
#####################################################################
# view {
#####################################################################
if ($action === 'view') {
//echo "<pre>"; print_r($_REQUEST); echo "</pre>";
$where = array();
if ($mac_addr_internal != '') {
$where[] = '`p`.`mac_addr` LIKE \'%' . $DB->escape($mac_addr_internal) . '%\'';
}
if ($pbx_id === 0) {
$where[] = '`h`.`is_foreign`=0';
} elseif ($pbx_id > 0) {
$where[] = '`h`.`id`=' . $pbx_id;
}
if ($ip_addr != '') {