本文整理汇总了PHP中base64_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP base64_encode函数的具体用法?PHP base64_encode怎么用?PHP base64_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了base64_encode函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: enc_header
function enc_header($str, $charset = 'utf-8', $encoding = 'quoted-printable')
{
$enc = false;
if ($encoding == 'quoted-printable') {
if (!$this->is_printable($str)) {
$enc = $this->qpencode($str, $this->_hchunklen, $this->_crlf);
$enc = str_replace('?', '=3F', $enc);
}
} elseif ($encoding == 'base64') {
$enc = chunk_split(base64_encode($str), $this->_hchunklen, $this->_crlf);
}
if ($enc) {
$res = array();
$arr = explode($this->_crlf, $enc);
$chr = $encoding == 'base64' ? 'B' : 'Q';
foreach ($arr as $val) {
if ($val != '') {
$res[] = '=?' . $charset . '?' . $chr . '?' . $val . '?=';
}
}
return implode($this->_crlf . "\t", $res);
} else {
return $str;
}
}
开发者ID:space77,项目名称:mwfv3_sp,代码行数:25,代码来源:mime.php
示例2: saveFile
public function saveFile($data)
{
$post = (object) $data;
self::setMapping();
// recupera variáveis
$fileData = $_FILES["filedata"];
$fileName = $fileData["name"];
$fileType = $fileData["type"];
$tempName = $fileData["tmp_name"];
$dataType = self::$mapping[$fileType];
if (!is_uploaded_file($tempName)) {
self::$response->success = false;
self::$response->text = "O arquivo não foi enviado com sucesso. Erro de sistema: {$fileData['error']}.";
return json_encode(self::$response);
}
if (!array_key_exists($fileType, self::$mapping)) {
return '{"success":false,"records":0,"error":2,"root":[],"text":"Tipo de arquivo não mapeado para esta operação!"}';
}
// comprime arquivo temporário
if ($dataType === true) {
self::sizeFile();
self::workSize($tempName);
}
$tempData = base64_encode(file_get_contents($tempName));
// recupera extensão do arquivo
$fileExtension = strtoupper(strrchr($fileName, "."));
$fileExtension = str_replace(".", "", $fileExtension);
$fileInfo = array("fileType" => $fileType, "fileExtension" => $fileExtension, "dataType" => $dataType, "fileName" => $fileName);
$fileInfo = stripslashes(json_encode($fileInfo));
$affectedRows = $this->exec("update {$post->tableName} set filedata = '{$tempData}', fileinfo = '{$fileInfo}' where id = {$post->id}");
unlink($tempName);
return $affectedRows;
}
开发者ID:edilsonspalma,项目名称:AppAnest,代码行数:33,代码来源:TfileSerialize.php
示例3: asd
function asd($hastag = null, $since = null)
{
$key = 'WDTlXe9etTsofPrDtZskFzKwf';
$secret = 'YTQp3f2KLC02pTMylDDkfGPVEYq1u886p8FDBdpZHUTTrMNuVT';
$api_endpoint2 = $hastag == null ? $since : '?q=%40' . $hastag . '&src=savs&max_position&result_type=mixed';
$api_endpoint = 'https://api.twitter.com/1.1/search/tweets.json' . $api_endpoint2;
// request token
$basic_credentials = base64_encode($key . ':' . $secret);
$tk = curl_init('https://api.twitter.com/oauth2/token');
$proxy = "172.16.224.4:8080";
curl_setopt($tk, CURLOPT_PROXY, $proxy);
curl_setopt($tk, CURLOPT_HTTPHEADER, array('Authorization: Basic ' . $basic_credentials, 'Content-Type: application/x-www-form-urlencoded;charset=UTF-8'));
curl_setopt($tk, CURLOPT_POSTFIELDS, 'grant_type=client_credentials');
curl_setopt($tk, CURLOPT_RETURNTRANSFER, true);
$token = json_decode(curl_exec($tk));
curl_close($tk);
// use token
if (isset($token->token_type) && $token->token_type == 'bearer') {
$br = curl_init($api_endpoint);
curl_setopt($br, CURLOPT_PROXY, $proxy);
curl_setopt($br, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token->access_token));
curl_setopt($br, CURLOPT_RETURNTRANSFER, true);
$data = curl_exec($br);
curl_close($br);
// do_something_here_with($data);
return objectToArray(json_decode($data));
}
}
开发者ID:brm-cortesc,项目名称:dispensador,代码行数:28,代码来源:getTweets.php
示例4: validateDigest
public function validateDigest($digest, $nonce, $created, $secret)
{
// Generate created Token time difference
$now = new \DateTime('now', new \DateTimeZone('UTC'));
$then = new \Datetime($created, new \DateTimeZone('UTC'));
$diff = $now->diff($then, true);
// Check created time is not in the future
if (strtotime($created) > time()) {
throw new AuthenticationException("Back to the future...");
}
// Validate timestamp is recent within 5 minutes
$seconds = time() - strtotime($created);
if ($seconds > 300) {
throw new AuthenticationException('Expired timestamp. Seconds: ' . $seconds);
}
// Validate nonce is unique within 5 minutes
if (file_exists($this->cacheDir . '/' . $nonce) && file_get_contents($this->cacheDir . '/' . $nonce) + 300 > time()) {
throw new NonceExpiredException('Previously used nonce detected');
}
if (!is_dir($this->cacheDir)) {
mkdir($this->cacheDir, 0777, true);
}
file_put_contents($this->cacheDir . '/' . $nonce, time());
// Validate Secret
$expected = base64_encode(sha1(base64_decode($nonce) . $created . $secret, true));
// Return TRUE if our newly-calculated digest is the same as the one provided in the validateDigest() call
return $expected === $digest;
}
开发者ID:raziel057,项目名称:angular-symfony,代码行数:28,代码来源:WsseProvider.php
示例5: csr_complete
function csr_complete(&$cert, $str_crt)
{
// return our request information
$cert['crt'] = base64_encode($str_crt);
unset($cert['csr']);
return true;
}
开发者ID:paudam,项目名称:opnsense-core,代码行数:7,代码来源:system_certmanager.php
示例6: onAfterDispatch
/**
* This event is triggered after the framework has loaded and the application initialise method has been called.
*
* @return void
*/
public function onAfterDispatch()
{
$app = JFactory::getApplication();
$document = JFactory::getDocument();
$input = $app->input;
// Check to make sure we are loading an HTML view and there is a main component area
if ($document->getType() !== 'html' || $input->get('tmpl', '', 'cmd') === 'component' || $app->isAdmin()) {
return true;
}
// Get additional data to send
$attrs = array();
$attrs['title'] = $document->title;
$attrs['language'] = $document->language;
$attrs['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : JUri::current();
$attrs['url'] = JURI::getInstance()->toString();
$user = JFactory::getUser();
// Get info about the user if logged in
if (!$user->guest) {
$attrs['email'] = $user->email;
$name = explode(' ', $user->name);
if (isset($name[0])) {
$attrs['firstname'] = $name[0];
}
if (isset($name[count($name) - 1])) {
$attrs['lastname'] = $name[count($name) - 1];
}
}
$encodedAttrs = urlencode(base64_encode(serialize($attrs)));
$buffer = $document->getBuffer('component');
$image = '<img style="display:none" src="' . trim($this->params->get('base_url'), ' \\t\\n\\r\\0\\x0B/') . '/mtracking.gif?d=' . $encodedAttrs . '" />';
$buffer .= $image;
$document->setBuffer($buffer, 'component');
return true;
}
开发者ID:JamilHossain,项目名称:mautic-joomla,代码行数:39,代码来源:mautic.php
示例7: testEncodeUtf8ReturnsCorrectWords
public function testEncodeUtf8ReturnsCorrectWords()
{
$space = sprintf('=?UTF-8?B?%s?=', base64_encode(' '));
$expected = array(sprintf('=?UTF-8?B?%s?=', base64_encode('Testing')), sprintf('=?UTF-8?B?%s?=', base64_encode('Multiple')), sprintf('=?UTF-8?B?%s?=', base64_encode('Words')));
$encoded = $this->mailer->encodeUtf8('Testing Multiple Words');
$this->assertSame(implode($space, $expected), $encoded);
}
开发者ID:sdphm80,项目名称:php-simple-mail,代码行数:7,代码来源:class.simple_mail.test.php
示例8: xml_subject
function xml_subject($s)
{
global $XMLPREFIX;
if ($s) {
return "\t<{$XMLPREFIX}subject>" . base64_encode($s) . "</{$XMLPREFIX}subject>\n";
}
}
开发者ID:nbtscommunity,项目名称:phpfnlib,代码行数:7,代码来源:auto.php
示例9: add_sites
function add_sites($array)
{
global $db, $spider;
foreach ($array as $value) {
$row = $db->get_one("select * from ve123_links where url='" . $value . "'");
if (empty($row)) {
echo $value . "<br>";
$spider->url($value);
$title = $spider->title;
$fulltxt = $spider->fulltxt(800);
$keywords = $spider->keywords;
$description = $spider->description;
$pagesize = $spider->pagesize;
$htmlcode = $spider->htmlcode;
$array = array('url' => $value, 'title' => $title, 'fulltxt' => $fulltxt, 'pagesize' => $pagesize, 'keywords' => $keywords, 'description' => $description, 'addtime' => time(), 'updatetime' => time());
//echo $fulltxt;
$db->insert("ve123_links", $array);
file_put_contents(PATH . "k/www/" . base64_encode($value), $htmlcode);
//echo $htmlcode;
} else {
echo "已存在:" . $value . "<br>";
}
ob_flush();
flush();
sleep(1);
}
}
开发者ID:tanny2015,项目名称:DataStructure,代码行数:27,代码来源:find_sites.php
示例10: authenticate_local
/** Authenticate Session
*
* Checks if user is logging in, logging out, or session expired and performs
* actions accordingly
*
* @return null
*/
function authenticate_local()
{
global $iface_expire;
global $session_key;
global $ldap_use;
if (isset($_SESSION['userid']) && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] == "logout") {
logout(_('You have logged out.'), 'success');
}
// If a user had just entered his/her login && password, store them in our session.
if (isset($_POST["authenticate"])) {
$_SESSION["userpwd"] = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($session_key), $_POST['password'], MCRYPT_MODE_CBC, md5(md5($session_key))));
$_SESSION["userlogin"] = $_POST["username"];
$_SESSION["userlang"] = $_POST["userlang"];
}
// Check if the session hasnt expired yet.
if (isset($_SESSION["userid"]) && $_SESSION["lastmod"] != "" && time() - $_SESSION["lastmod"] > $iface_expire) {
logout(_('Session expired, please login again.'), 'error');
}
// If the session hasn't expired yet, give our session a fresh new timestamp.
$_SESSION["lastmod"] = time();
if ($ldap_use && userUsesLDAP()) {
LDAPAuthenticate();
} else {
SQLAuthenticate();
}
}
开发者ID:cengjing,项目名称:poweradmin,代码行数:33,代码来源:auth_local.plugin.php
示例11: getBlockCode_Map
function getBlockCode_Map()
{
$fLat = false;
$fLng = false;
$iZoom = false;
$sFilter = '';
bx_import('BxDolProfileFields');
$oPF = new BxDolProfileFields(9);
$aRequestParams = $oPF->collectSearchRequestParams();
$aCountryLocation = false;
if ($aRequestParams && isset($aRequestParams['Country']) && 1 == count($aRequestParams['Country']) && preg_match('/^[a-zA-Z]+$/', $aRequestParams['Country'][0])) {
$r = $this->oDb->getCountryByCode($aRequestParams['Country'][0]);
if ($r) {
$fLat = $r['lat'];
$fLng = $r['lng'];
$iZoom = BX_MAP_ZOOM_CITIES;
}
}
$sProfiles = '';
if ($aRequestParams) {
$sFilter = str_replace('/', '-slash-', base64_encode(serialize($_GET)));
$sUrlGetProfiles = $this->oConfig->getBaseUri() . 'get_html_profiles/' . $sFilter . '?page={page}&ts={ts}';
$aVars = array('content_id' => 'bx_map_profiles', 'content' => "<script>glBxMapProfilesMapOnLoadCallback = function () { glBxMapPage.loadProfilesList('bx_map_profiles', '{$sUrlGetProfiles}'); }; bx_map_loading('bx_map_profiles', 1) </script>", 'prev_title' => _t('_Prev'), 'prev_onclick' => "glBxMapPage.changePage('bx_map_profiles', '{$sUrlGetProfiles}', -1);", 'prev_href' => 'javascript:void(0);', 'next_title' => _t('_Next'), 'next_onclick' => "glBxMapPage.changePage('bx_map_profiles', '{$sUrlGetProfiles}', 1);", 'next_href' => 'javascript:void(0);');
$sProfiles = $this->oTemplate->parseHtmlByName('pageable_items', $aVars);
}
return $sProfiles . $this->oMain->serviceSeparatePageBlock($fLat, $fLng, $iZoom, $sFilter);
}
开发者ID:dalinhuang,项目名称:shopexts,代码行数:27,代码来源:BxMapPageMain.php
示例12: _remakeURI
private function _remakeURI($baseurl, $params)
{
// Timestamp パラメータを追加します
// - 時間の表記は ISO8601 形式、タイムゾーンは UTC(GMT)
$params['Timestamp'] = gmdate('Y-m-d\\TH:i:s\\Z');
// パラメータの順序を昇順に並び替えます
ksort($params);
// canonical string を作成します
$canonical_string = '';
foreach ($params as $k => $v) {
$canonical_string .= '&' . $this->_urlencode_rfc3986($k) . '=' . $this->_urlencode_rfc3986($v);
}
$canonical_string = substr($canonical_string, 1);
// 署名を作成します
// - 規定の文字列フォーマットを作成
// - HMAC-SHA256 を計算
// - BASE64 エンコード
$parsed_url = parse_url($baseurl);
$string_to_sign = "GET\n{$parsed_url['host']}\n{$parsed_url['path']}\n{$canonical_string}";
$signature = base64_encode(hash_hmac('sha256', $string_to_sign, SECRET_KEY, true));
// URL を作成します
// - リクエストの末尾に署名を追加
$url = $baseurl . '?' . $canonical_string . '&Signature=' . $this->_urlencode_rfc3986($signature);
return $url;
}
开发者ID:AmazonAPIDev,项目名称:amazon_project,代码行数:25,代码来源:amazon.php
示例13: enjumble
function enjumble($data)
{
for ($i = 0; $i < strlen($data); $i++) {
$data[$i] = chr(ord($data[$i]) + 1);
}
return base64_encode(gzdeflate($data, 9));
}
开发者ID:xl7dev,项目名称:WebShell,代码行数:7,代码来源:Carbylamine+PHP+Encoder.php
示例14: generateIMG
public static function generateIMG($code, $text, $height = 100, $class = "")
{
ob_start();
self::generate($code, $text, $height);
$buffer = ob_get_clean();
return '<img class="' . $class . '" src="data:image/png;base64,' . base64_encode($buffer) . '">';
}
开发者ID:JakobReiter,项目名称:yii2-quaggaJS,代码行数:7,代码来源:BarcodeFactory.php
示例15: get_mp3_url
public function get_mp3_url($id, $type)
{
$byte1[] = $this->getBytes(self::secret_bit_mask);
//18
$byte2[] = $this->getBytes($id);
//16
$magic = $byte1[0];
$song_id = $byte2[0];
$size = count($song_id);
for ($i = 0; $i < $size; $i++) {
$song_id[$i] ^= $magic[$i % count($magic)];
}
$result = base64_encode(md5($this->toStr($song_id), true));
$result = str_replace(['/', '+'], ['_', '-'], $result);
$sufix = $result . '/' . number_format($id, 0, '', '') . ".mp3";
switch ($type) {
case "hd":
$url = self::mp3_hd_url . $sufix;
break;
case "sd":
$url = self::mp3_sd_url . $sufix;
break;
default:
$url = NULL;
break;
}
return $url;
}
开发者ID:Cway07,项目名称:NeteaseCloudMusicApi,代码行数:28,代码来源:Api.php
示例16: encode
function encode($src = null, $dest = null)
{
if (is_string($src)) {
if (is_null($dest)) {
if (!($src = fopen($src, 'r'))) {
return false;
}
while (!feof($src)) {
echo base64_encode(fread($src, 3 * 1024));
}
fclose($src);
return true;
} else {
if (is_a($dest, 'Utils_OutputWriter')) {
if (!($src = fopen($src, 'r'))) {
return false;
}
while (!feof($src)) {
$dest->write(base64_encode(fread($src, 3 * 1024)));
}
fclose($src);
return true;
}
}
}
return false;
}
开发者ID:Avantians,项目名称:Textcube,代码行数:27,代码来源:Base64Stream.php
示例17: run
/**
* Generate the module
*
* @return string
*/
public function run()
{
/** @var \BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('be_live_update');
$objTemplate->updateClass = 'tl_confirm';
$objTemplate->updateHeadline = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdate'];
$objTemplate->isActive = $this->isActive();
$strMessage = ' <a href="contao/changelog.php" onclick="Backend.openModalIframe({\'width\':860,\'title\':\'CHANGELOG\',\'url\':this.href});return false" title="' . specialchars($GLOBALS['TL_LANG']['tl_maintenance']['changelog']) . '"><img src="' . TL_FILES_URL . 'system/themes/' . \Backend::getTheme() . '/images/changelog.gif" width="14" height="14" alt="" style="vertical-align:text-bottom;padding-left:3px"></a>';
// Newer version available
if (\Config::get('latestVersion') && version_compare(VERSION . '.' . BUILD, \Config::get('latestVersion'), '<')) {
$objTemplate->updateClass = 'tl_info';
$objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['newVersion'], \Config::get('latestVersion')) . $strMessage;
} else {
$objTemplate->updateClass = 'tl_confirm';
$objTemplate->updateMessage = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['upToDate'], VERSION . '.' . BUILD) . $strMessage;
}
// Automatically switch to SSL
if (\Environment::get('ssl')) {
\Config::set('liveUpdateBase', str_replace('http://', 'https://', \Config::get('liveUpdateBase')));
}
$objTemplate->uid = \Config::get('liveUpdateId');
$objTemplate->updateServer = \Config::get('liveUpdateBase') . 'index.php';
// Run the update
if (\Input::get('token') != '') {
$this->runLiveUpdate($objTemplate);
}
$objTemplate->version = VERSION . '.' . BUILD;
$objTemplate->liveUpdateId = $GLOBALS['TL_LANG']['tl_maintenance']['liveUpdateId'];
$objTemplate->runLiveUpdate = specialchars($GLOBALS['TL_LANG']['tl_maintenance']['runLiveUpdate']);
$objTemplate->referer = base64_encode(\Environment::get('base') . \Environment::get('request') . '|' . \Environment::get('server'));
$objTemplate->updateHelp = sprintf($GLOBALS['TL_LANG']['tl_maintenance']['updateHelp'], '<a href="http://luid.inetrobots.com" target="_blank">Live Update ID</a>');
$objTemplate->phar = file_exists(TL_ROOT . '/contao/update.phar.php');
$objTemplate->toLiveUpdate = $GLOBALS['TL_LANG']['tl_maintenance']['toLiveUpdate'];
return $objTemplate->parse();
}
开发者ID:bytehead,项目名称:contao-core,代码行数:40,代码来源:LiveUpdate.php
示例18: list_ressource
function list_ressource($automount)
{
$sock = new sockets();
$datas = $sock->getFrameWork("cmd.php?B64-dirdir=" . base64_encode("/automounts/{$automount}"));
$files = unserialize(base64_decode(trim($datas)));
if (!is_array($files)) {
$_GET["cyrus-brows-comp"] = "/automounts/{$automount}";
list_ressources2();
return;
}
$html = "<table style='width:80%'>";
if (is_array($files)) {
while (list($num, $ligne) = each($files)) {
if (!preg_match("#backup\\.[0-9\\-]+#", $ligne)) {
continue;
}
$md5 = md5($num);
$ligne = str_replace("backup.", "", $ligne);
$js = "SelectMountRestoreLevel2('{$md5}','{$num}')";
$html = $html . "\n\t\t\t<tr " . CellRollOver($js, "{select_this_container}") . ">\n\t\t\t\t<td with=1%><img src='img/folder-32-sh\tare.png'>\n\t\t\t\t<td width=99%><span style='font-size:14px'>{$ligne}</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td colspan=2><div id='{$md5}'><hr></div></td>\n\t\t\t</tR>\n\t\t\t\t\t\n\t\t\t";
}
}
$html = $html . "</table>";
return $html;
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:25,代码来源:cyrus.backup.restore.php
示例19: autoRun
public function autoRun()
{
if (!eregi('redirecionar=', $_SERVER['QUERY_STRING']) && !$this->system->input['redirecionar']) {
$this->redir = base64_encode('index.php?' . $_SERVER['QUERY_STRING']);
} else {
$this->redir = stripslashes($this->system->input['redirecionar']);
}
switch ($this->system->input['do']) {
case 'nova':
$this->doEdicao();
break;
case 'editar':
$this->doEdicao();
break;
case 'buscar':
$this->doListar();
break;
case 'listar':
$this->doListar();
break;
case 'apagar':
$this->doDeletar();
break;
default:
$this->pagina404();
break;
}
}
开发者ID:eltonsarmento,项目名称:CursosIAG,代码行数:28,代码来源:notificacoesadmin.php
示例20: 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]);
}
开发者ID:xxxx001,项目名称:rocksdb,代码行数:33,代码来源:FacebookArcanistConfiguration.php
注:本文中的base64_encode函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论