当前位置: 首页>>代码示例>>PHP>>正文


PHP base64_encode函数代码示例

本文整理汇总了PHP中base64_encode函数的典型用法代码示例。如果您正苦于以下问题:PHP base64_encode函数的具体用法?PHP base64_encode怎么用?PHP base64_encode使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了base64_encode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的base64_encode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。