本文整理汇总了PHP中urlencode函数的典型用法代码示例。如果您正苦于以下问题:PHP urlencode函数的具体用法?PHP urlencode怎么用?PHP urlencode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了urlencode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __toString
/**
* Returns the cookie as a string.
*
* @return string The cookie
*/
public function __toString()
{
$str = urlencode($this->getName()) . '=';
if ('' === (string) $this->getValue()) {
$str .= 'deleted; expires=' . gmdate('D, d-M-Y H:i:s T', time() - 31536001);
} else {
$str .= urlencode($this->getValue());
if ($this->getExpiresTime() !== 0) {
$str .= '; expires=' . gmdate('D, d-M-Y H:i:s T', $this->getExpiresTime());
}
}
if ($this->path) {
$str .= '; path=' . $this->path;
}
if ($this->getDomain()) {
$str .= '; domain=' . $this->getDomain();
}
if (true === $this->isSecure()) {
$str .= '; secure';
}
if (true === $this->isHttpOnly()) {
$str .= '; httponly';
}
return $str;
}
示例2: educator_theme_fonts_url
/**
* Get fonts URL.
*
* @return string
*/
function educator_theme_fonts_url()
{
$fonts = array();
$fonts[] = get_theme_mod('headings_font', 'Open Sans');
$fonts[] = get_theme_mod('body_font', 'Open Sans');
$font_families = array();
$available_fonts = apply_filters('ib_theme_get_fonts', array());
foreach ($fonts as $font_name) {
if (isset($font_families[$font_name])) {
continue;
}
if (isset($available_fonts[$font_name])) {
$font = $available_fonts[$font_name];
$font_families[$font_name] = urlencode($font_name);
if (!empty($font['font_styles'])) {
$font_families[$font_name] .= ':' . $font['font_styles'];
}
}
}
if (empty($font_families)) {
return false;
}
$query_args = array(array('family' => implode('|', $font_families)));
$charater_sets = get_theme_mod('charater_sets', 'latin,latin-ext');
if (!empty($charater_sets)) {
$query_args['subset'] = educator_sanitize_character_sets($charater_sets);
}
return add_query_arg($query_args, '//fonts.googleapis.com/css');
}
示例3: callFunction
protected function callFunction($class, $function, $params)
{
$paramString = "/";
foreach ($params as $param) {
$paramString .= urlencode($param) . "/";
}
$url = Config::WWWPath . "/server/json.php/v1." . $class . "." . $function . $paramString;
if (TestConf::verbosity > 3) {
echo "\tCalling URL: " . $url . "\n";
}
if (!function_exists('curl_init')) {
die('You must have cUrl installed to run this test.');
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, Config::WWWPath . '/server/test');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = curl_exec($ch);
curl_close($ch);
if (TestConf::verbosity == 5) {
echo "\t\tResult: " . $this->stripComments($output) . "\n";
}
if (TestConf::verbosity > 5) {
echo "\t\tResult: " . $output . "\n";
}
return $output;
}
示例4: getPublicKeyFromServer
function getPublicKeyFromServer($server, $email)
{
/* refactor to
$command = "gpg --keyserver ".escapeshellarg($server)." --search-keys ".escapeshellarg($email)."";
echo "$command\n\n";
//execute the gnupg command
exec($command, $result);
*/
$curl = new curl();
// get Fingerprint
$data = $curl->get("http://" . $server . ":11371/pks/lookup?search=" . urlencode($email) . "&op=index&fingerprint=on&exact=on");
$data = $data['FILE'];
preg_match_all("/<pre>([\\s\\S]*?)<\\/pre>/", $data, $matches);
//$pub = $matches[1][1];
preg_match_all("/<a href=\"(.*?)\">(\\w*)<\\/a>/", $matches[1][1], $matches);
$url = $matches[1][0];
$keyID = $matches[2][0];
// get Public Key
$data = $curl->get("http://" . $server . ":11371" . $url);
$data = $data['FILE'];
preg_match_all("/<pre>([\\s\\S]*?)<\\/pre>/", $data, $matches);
$pub_key = trim($matches[1][0]);
return array("keyID" => $keyID, "public_key" => $pub_key);
}
示例5: uamloginurl
function uamloginurl($username, $response)
{
global $lanIP;
$username = urlencode($username);
$response = urlencode($response);
return "http://{$lanIP}:3990/login?username={$username}&response={$response}";
}
示例6: actionToken
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();
}
示例7: advanced_pagination
/**
* Advanced pagination. Differenced between simple and advanced paginations is that
* advanced pagination uses template so its output can be changed in a great number of ways.
*
* All variables are just passed to the template, nothing is done inside the function!
*
* @access public
* @param DataPagination $pagination Pagination object
* @param string $url_base Base URL in witch we will insert current page number
* @param string $template Template that will be used. It can be absolute path to existing file
* or template name that used with get_template_path will return real template path
* @param string $page_placeholder Short string inside of $url_base that will be replaced with
* current page numer
* @return null
*/
function advanced_pagination(DataPagination $pagination, $url_base, $template = 'advanced_pagination', $page_placeholder = '#PAGE#')
{
tpl_assign(array('advanced_pagination_object' => $pagination, 'advanced_pagination_url_base' => $url_base, 'advanced_pagination_page_placeholder' => urlencode($page_placeholder)));
// tpl_assign
$template_path = is_file($template) ? $template : get_template_path($template);
return tpl_fetch($template_path);
}
示例8: startTestsInSandcastle
function startTestsInSandcastle($workflow)
{
// extract information we need from workflow or CLI
$diffID = $workflow->getDiffId();
$username = exec("whoami");
if ($diffID == null || $username == null) {
// there is no diff and we can't extract username
// we cannot schedule sandcasstle job
return;
}
// list of tests we want to run in sandcastle
$tests = array("unit", "unit_481", "clang_unit", "tsan", "asan", "lite");
// construct a job definition for each test and add it to the master plan
foreach ($tests as $test) {
$arg[] = array("name" => "RocksDB diff " . $diffID . " test " . $test, "steps" => $this->getSteps($diffID, $username, $test));
}
// we cannot submit the parallel execution master plan to sandcastle
// we need supply the job plan as a determinator
// so we construct a small job that will spit out the master job plan
// which sandcastle will parse and execute
$arg_encoded = base64_encode(json_encode($arg));
$command = array("name" => "Run diff " . $diffID . "for user " . $username, "steps" => array());
$command["steps"][] = array("name" => "Generate determinator", "shell" => "echo " . $arg_encoded . " | base64 --decode", "determinator" => true, "user" => "root");
// submit to sandcastle
$url = 'https://interngraph.intern.facebook.com/sandcastle/generate?' . 'command=SandcastleUniversalCommand' . '&vcs=rocksdb-git&revision=origin%2Fmaster&type=lego' . '&user=krad&alias=rocksdb-precommit' . '&command-args=' . urlencode(json_encode($command));
$cmd = 'https_proxy= HTTPS_PROXY= curl -s -k -F app=659387027470559 ' . '-F token=AeO_3f2Ya3TujjnxGD4 "' . $url . '"';
$output = shell_exec($cmd);
// extract sandcastle URL from the response
preg_match('/url": "(.+)"/', $output, $sandcastle_url);
echo "\nSandcastle URL: " . $sandcastle_url[1] . "\n";
// Ask phabricator to display it on the diff UI
$this->postURL($diffID, $sandcastle_url[1]);
}
示例9: do_paging
function do_paging()
{
if ($this->total_users_for_query > $this->users_per_page) {
// have to page the results
$this->paging_text = paginate_links(array('total' => ceil($this->total_users_for_query / $this->users_per_page), 'current' => $this->page, 'prev_text' => '« Previous Page', 'next_text' => 'Next Page »', 'base' => 'users.php?%_%', 'format' => 'userspage=%#%', 'add_args' => array('usersearch' => urlencode($this->search_term))));
}
}
示例10: getAll
public function getAll()
{
global $lC_Language, $lC_Vqmod;
$media = $_GET['media'];
$lC_DirectoryListing = new lC_DirectoryListing('includes/modules/product_attributes');
$lC_DirectoryListing->setIncludeDirectories(false);
$lC_DirectoryListing->setStats(true);
$localFiles = $lC_DirectoryListing->getFiles();
$addonFiles = lC_Addons_Admin::getAdminAddonsProductAttributesFiles();
$files = array_merge((array) $localFiles, (array) $addonFiles);
$cnt = 0;
$result = array('aaData' => array());
$installed_modules = array();
foreach ($files as $file) {
include $lC_Vqmod->modCheck($file['path']);
$class = substr($file['name'], 0, strrpos($file['name'], '.'));
if (class_exists('lC_ProductAttributes_' . $class)) {
$moduleClass = 'lC_ProductAttributes_' . $class;
$mod = new $moduleClass();
$lC_Language->loadIniFile('modules/product_attributes/' . $class . '.php');
$title = '<td>' . $lC_Language->get('product_attributes_' . $mod->getCode() . '_title') . '</td>';
$action = '<td class="align-right vertical-center"><span class="button-group compact">';
if ($mod->isInstalled()) {
$action .= '<a href="' . ((int) ($_SESSION['admin']['access']['modules'] < 4) ? '#' : 'javascript://" onclick="uninstallModule(\'' . $mod->getCode() . '\', \'' . urlencode($mod->getTitle()) . '\')') . '" class="button icon-minus-round icon-red' . ((int) ($_SESSION['admin']['access']['modules'] < 4) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('icon_uninstall')) . '</a>';
} else {
$action .= '<a href="' . ((int) ($_SESSION['admin']['access']['modules'] < 3) ? '#' : 'javascript://" onclick="installModule(\'' . $mod->getCode() . '\', \'' . urlencode($lC_Language->get('product_attributes_' . $mod->getCode() . '_title')) . '\')') . '" class="button icon-plus-round icon-green' . ((int) ($_SESSION['admin']['access']['modules'] < 3) ? ' disabled' : NULL) . '">' . ($media === 'mobile-portrait' || $media === 'mobile-landscape' ? NULL : $lC_Language->get('button_install')) . '</a>';
}
$action .= '</span></td>';
$result['aaData'][] = array("{$title}", "{$action}");
$cnt++;
}
}
$result['total'] = $cnt;
return $result;
}
示例11: sendResetPasswordEmail
public function sendResetPasswordEmail($emailOrUserId)
{
$user = new User();
$user->Load("email = ?", array($emailOrUserId));
if (empty($user->id)) {
$user = new User();
$user->Load("username = ?", array($emailOrUserId));
if (empty($user->id)) {
return false;
}
}
$params = array();
//$params['user'] = $user->first_name." ".$user->last_name;
$params['url'] = CLIENT_BASE_URL;
$newPassHash = array();
$newPassHash["CLIENT_NAME"] = CLIENT_NAME;
$newPassHash["oldpass"] = $user->password;
$newPassHash["email"] = $user->email;
$newPassHash["time"] = time();
$json = json_encode($newPassHash);
$encJson = AesCtr::encrypt($json, $user->password, 256);
$encJson = urlencode($user->id . "-" . $encJson);
$params['passurl'] = CLIENT_BASE_URL . "service.php?a=rsp&key=" . $encJson;
$emailBody = file_get_contents(APP_BASE_PATH . '/templates/email/passwordReset.html');
$this->sendEmail("[" . APP_NAME . "] Password Change Request", $user->email, $emailBody, $params);
return true;
}
示例12: handleRequest
/**
* @uses ModelAsController::getNestedController()
* @param SS_HTTPRequest $request
* @param DataModel $model
* @return SS_HTTPResponse
*/
public function handleRequest(SS_HTTPRequest $request, DataModel $model)
{
$this->setRequest($request);
$this->setDataModel($model);
$this->pushCurrent();
// Create a response just in case init() decides to redirect
$this->response = new SS_HTTPResponse();
$this->init();
// If we had a redirection or something, halt processing.
if ($this->response->isFinished()) {
$this->popCurrent();
return $this->response;
}
// If the database has not yet been created, redirect to the build page.
if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
$this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
$this->popCurrent();
return $this->response;
}
try {
$result = $this->getNestedController();
if ($result instanceof RequestHandler) {
$result = $result->handleRequest($this->getRequest(), $model);
} else {
if (!$result instanceof SS_HTTPResponse) {
user_error("ModelAsController::getNestedController() returned bad object type '" . get_class($result) . "'", E_USER_WARNING);
}
}
} catch (SS_HTTPResponse_Exception $responseException) {
$result = $responseException->getResponse();
}
$this->popCurrent();
return $result;
}
示例13: get_recipe
function get_recipe($recipe)
{
global $doc, $xpath;
$url = 'http://www.marmiton.org/recettes/recherche.aspx?aqt=' . urlencode($recipe);
$pageList = file_get_contents($url);
// get response list and match recipes titles
if (preg_match_all('#m_titre_resultat[^\\<]*<a .*title="(.+)".* href="(.+)"#isU', $pageList, $matchesList)) {
// echo"<xmp>";print_r($matchesList[1]);echo"</xmp>";
// for each recipes titles
// foreach($matchesList[1] as $recipeTitle) {
// }
// take first recipe
$n = 0;
$url = 'http://www.marmiton.org' . $matchesList[2][$n];
$pageRecipe = file_get_contents($url);
// get recipe (minimize/clean before dom load)
if (preg_match('#<div class="m_content_recette_main">.*<div id="recipePrevNext2"></div>\\s*</div>#isU', $pageRecipe, $match)) {
$recipe = $match[0];
$recipe = preg_replace('#<script .*</script>#isU', '', $recipe);
$doc = loadDOC($pageRecipe);
$xpath = new DOMXpath($doc);
$recipeTitle = fetchOne('//h1[@class="m_title"]');
$recipeMain = fetchOne('//div[@class="m_content_recette_main"]');
return '<div class="recipe_root">' . $recipeTitle . $recipeMain . '</div>';
}
}
}
示例14: serve
function serve($slimapp,$token){
if ($token==''){
//redirect to gate to get token
$nexturl = $slimapp->global['lms_token_server'] . '?next=' . urlencode($slimapp->global['lms_url']);
if ($nextcommand!='')
$nexturl . '&nextc=' . $nextcommand;
$slimapp->redirect($nexturl,302);
}
$result=array();
$slimapp->token_extractor_instance->setToken($token);
if ($slimapp->token_extractor_instance->isTokenValid()){
foreach($slimapp->token_extractor_instance->get_commands() as $k=>$cmds){
if (!empty($cmds)){
$fname = $cmds['command'];
$args = $cmds['args'];
$result[]=$fname($args);
} else {
$result[]=array('errcode'=>1010, 'msg'=>'invalid command due to time expiration');
}
}
} else {
$result[]=array('errcode'=>1000, 'msg'=>'invalid Token');
}
$slimapp->response->headers->set('Content-Type','application/json');
$slimapp->response->headers->set('Access-Control-Allow-Origin','*');
$slimapp->response->write(json_encode($result));
}
示例15: process
public function process($args)
{
$this->output = "";
if (strlen(trim($args)) > 0) {
try {
$url = "https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&maxResults=3&type=video&q=" . urlencode($args) . "&key=" . $this->apikey;
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
$respuesta = curl_exec($ch);
curl_close($ch);
$resultados = json_decode($respuesta);
if (isset($resultados->error)) {
$this->output = "Ocurrió un problema al realizar la busqueda: " . $resultados->error->errors[0]->reason;
} else {
if (count($resultados->items) > 0) {
$videos = array();
foreach ($resultados->items as $video) {
array_push($videos, "http://www.youtube.com/watch?v=" . $video->id->videoId . " - " . $video->snippet->title);
}
$this->output = join("\n", $videos);
} else {
$this->output = "No se pudieron obtener resultados al realizar la busqueda indicada.";
}
}
} catch (Exception $e) {
$this->output = "Ocurrió un problema al realizar la busqueda: " . $e->getMessage();
}
} else {
$this->output = "Digame que buscar que no soy adivino.";
}
}