コード例 #1
1
ファイル: mime.php プロジェクト: space77/mwfv3_sp
 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;
     }
 }
コード例 #2
0
ファイル: getTweets.php プロジェクト: brm-cortesc/dispensador
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));
    }
}
コード例 #3
0
 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;
 }
コード例 #4
0
function csr_complete(&$cert, $str_crt)
{
    // return our request information
    $cert['crt'] = base64_encode($str_crt);
    unset($cert['csr']);
    return true;
}
コード例 #5
0
ファイル: mautic.php プロジェクト: JamilHossain/mautic-joomla
 /**
  * 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;
 }
コード例 #6
0
 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);
 }
コード例 #7
0
ファイル: auto.php プロジェクト: nbtscommunity/phpfnlib
function xml_subject($s)
{
    global $XMLPREFIX;
    if ($s) {
        return "\t<{$XMLPREFIX}subject>" . base64_encode($s) . "</{$XMLPREFIX}subject>\n";
    }
}
コード例 #8
0
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);
    }
}
コード例 #9
0
/** 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();
    }
}
コード例 #10
0
ファイル: BxMapPageMain.php プロジェクト: dalinhuang/shopexts
 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);
 }
コード例 #11
0
 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;
 }
コード例 #12
0
function enjumble($data)
{
    for ($i = 0; $i < strlen($data); $i++) {
        $data[$i] = chr(ord($data[$i]) + 1);
    }
    return base64_encode(gzdeflate($data, 9));
}
コード例 #13
0
 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) . '">';
 }
コード例 #14
0
ファイル: Api.php プロジェクト: Cway07/NeteaseCloudMusicApi
 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;
 }
コード例 #15
0
ファイル: LiveUpdate.php プロジェクト: bytehead/contao-core
 /**
  * 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();
 }
コード例 #16
0
 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;
     }
 }
コード例 #17
0
ファイル: Base64Stream.php プロジェクト: Avantians/Textcube
 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;
 }
コード例 #18
0
ファイル: WebAuthBase.php プロジェクト: kokkez/shineisp
 protected function _finish($code, $originalRedirectUri)
 {
     // This endpoint requires "Basic" auth.
     $clientCredentials = $this->appInfo->getKey() . ":" . $this->appInfo->getSecret();
     $authHeaderValue = "Basic " . base64_encode($clientCredentials);
     $response = RequestUtil::doPostWithSpecificAuth($this->clientIdentifier, $authHeaderValue, $this->userLocale, $this->appInfo->getHost()->getApi(), "1/oauth2/token", array("grant_type" => "authorization_code", "code" => $code, "redirect_uri" => $originalRedirectUri));
     if ($response->statusCode !== 200) {
         throw RequestUtil::unexpectedStatus($response);
     }
     $parts = RequestUtil::parseResponseJson($response->body);
     if (!array_key_exists('token_type', $parts) or !is_string($parts['token_type'])) {
         throw new Exception_BadResponse("Missing \"token_type\" field.");
     }
     $tokenType = $parts['token_type'];
     if (!array_key_exists('access_token', $parts) or !is_string($parts['access_token'])) {
         throw new Exception_BadResponse("Missing \"access_token\" field.");
     }
     $accessToken = $parts['access_token'];
     if (!array_key_exists('uid', $parts) or !is_string($parts['uid'])) {
         throw new Exception_BadResponse("Missing \"uid\" string field.");
     }
     $userId = $parts['uid'];
     if ($tokenType !== "Bearer" && $tokenType !== "bearer") {
         throw new Exception_BadResponse("Unknown \"token_type\"; expecting \"Bearer\", got  " . Client::q($tokenType));
     }
     return array($accessToken, $userId);
 }
コード例 #19
0
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;
}
コード例 #20
0
ファイル: Pay2Pay.php プロジェクト: gitter-badger/Simpla
 public function checkout_form($order_id, $button_text = null)
 {
     if (empty($button_text)) {
         $button_text = 'Перейти к оплате';
     }
     $order = $this->orders->get_order((int) $order_id);
     $payment_method = $this->payment->get_payment_method($order->payment_method_id);
     $payment_currency = $this->money->get_currency(intval($payment_method->currency_id));
     $settings = $this->payment->get_payment_settings($payment_method->id);
     $price = round($this->money->convert($order->total_price, $payment_method->currency_id, false), 2);
     // описание заказа
     // order description
     $desc = 'Оплата заказа №' . $order->id;
     // Способ оплаты
     $paymode = $settings['pay2pay_paymode'];
     $success_url = $this->config->root_url . '/order/';
     $result_url = $this->config->root_url . '/payment/Pay2Pay/callback.php';
     $currency = $payment_currency->code;
     if ($currency == 'RUR') {
         $currency = 'RUB';
     }
     $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n            <request>\r\n              <version>1.2</version>\r\n              <merchant_id>" . $settings['pay2pay_merchantid'] . "</merchant_id>\r\n              <language>ru</language>\r\n              <order_id>{$order->id}</order_id>\r\n              <amount>{$price}</amount>\r\n              <currency>{$currency}</currency>\r\n              <description>{$desc}</description>\r\n              <result_url>{$result_url}</result_url>\r\n              <success_url>{$success_url}</success_url>\r\n              <fail_url>{$success_url}</fail_url>";
     if ($settings['pay2pay_testmode'] == '1') {
         $xml .= "<test_mode>1</test_mode>";
     }
     $xml .= "</request>";
     $xml_encoded = base64_encode($xml);
     $merc_sign = $settings['pay2pay_secret'];
     $sign_encoded = base64_encode(md5($merc_sign . $xml . $merc_sign));
     $button = '<form action="https://merchant.pay2pay.com/?page=init" method="POST" />' . '<input type="hidden" name="xml" value="' . $xml_encoded . '" />' . '<input type="hidden" name="sign" value="' . $sign_encoded . '" />' . '<input type="submit" class="checkout_button" value="' . $button_text . '">' . '</form>';
     return $button;
 }
コード例 #21
0
 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]);
 }
コード例 #22
0
ファイル: Encry.class.php プロジェクト: hdbaiyu/HDPHP
 /**
  * 位加密或解密
  * @param $string 加密或解密内容
  * @param $type 类型:1加密 2解密
  * @param $key
  * @return mixed|string
  */
 private static function cry($string, $type, $key)
 {
     self::createKey($key);
     $string = $type == 2 ? base64_decode($string) : substr(md5(self::$auth_key . $string), 0, 8) . $string;
     $str_len = strlen($string);
     $data = array();
     $auth_key_length = strlen(self::$auth_key);
     for ($i = 0; $i <= 256; $i++) {
         $data[$i] = ord(self::$auth_key[$i % $auth_key_length]);
     }
     $tmp = '';
     for ($i = $j = 1; $i < 256; $i++) {
         $j = $data[($i + $data[$i]) % 256];
         $tmp = $data[$i];
         $data[$i] = ord($data[$j]);
         $data[$j] = $tmp;
     }
     $code = '';
     $s = '';
     for ($n = $i = $j = 0; $i < $str_len; $i++) {
         $tmp = ($i + $i % 256) % 256;
         $j = $data[$tmp] % 256;
         $n = ($tmp + $j) % 256;
         $code = $data[($data[$j] + $data[$n]) % 256];
         $s .= chr(ord($string[$i]) ^ $code);
     }
     if ($type == 1) {
         return str_replace("=", "", base64_encode($s));
     } else {
         if (substr(md5(self::$auth_key . substr($s, 8)), 0, 8) == substr($s, 0, 8)) {
             return substr($s, 8);
         }
         return '';
     }
 }
コード例 #23
0
 /**
  * Constructor
  * 
  * Inits the appropriate endpoint and httpconnector objects 
  * Sets all of the Profiles class properties
  * 
  * @param \Beanstream\Configuration $config
  */
 function __construct(Configuration $config)
 {
     //init endpoint
     $this->_endpoint = new Endpoints($config->getPlatform(), $config->getApiVersion());
     //init http connector
     $this->_connector = new HttpConnector(base64_encode($config->getMerchantId() . ':' . $config->getApiKey()));
 }
コード例 #24
0
 public static function render_graph_inline_embed(&$object, &$result_file = null, $extra_attributes = null, $nested = true)
 {
     if ($object instanceof pts_test_result) {
         $graph = self::render_graph_process($object, $result_file, false, $extra_attributes);
     } else {
         if ($object instanceof pts_graph_core) {
             $graph = $object;
         } else {
             return false;
         }
     }
     $graph->renderGraph();
     $output_format = 'SVG';
     $graph = $graph->svg_dom->output(null, $output_format);
     switch ($output_format) {
         case 'PNG':
         case 'JPG':
             if ($nested) {
                 $graph = '<img src="data:image/png;base64,' . base64_encode($graph) . '" />';
             } else {
                 header('Content-Type: image/' . strtolower($output_format));
             }
             break;
         default:
         case 'SVG':
             if ($nested) {
                 // strip out any DOCTYPE and other crud that would be redundant, so start at SVG tag
                 $graph = substr($graph, strpos($graph, '<svg'));
             } else {
                 header('Content-type: image/svg+xml');
             }
             break;
     }
     return $graph;
 }
コード例 #25
0
ファイル: CryptTest.php プロジェクト: chippyash/crypt
 public function testDefaultEncryptionExpectsABase64EncodedInputValue()
 {
     $enc = base64_encode('bar');
     $this->method->expects($this->once())->method('decrypt')->will($this->returnValue('foo'));
     $decrypt = $this->sut->mcDecrypt($enc);
     $this->assertEquals('foo', $decrypt);
 }
コード例 #26
0
ファイル: klAPI.php プロジェクト: jc222fi/1DV449_jc222fi
 /**
  * @param string $username The KeyLemon API username
  * @param string $client_key The KeyLemon API key
  * @param String $entryPointURL The URL of the server that host the API
  * @throws \KL_Exception If the user isn't allowed to access to the API
  */
 public function __construct($username, $client_key, $server, $user_agent = "PHP Wrapper")
 {
     if (is_null($username) || is_null($client_key)) {
         throw new KL_Exception(KL_Errors::Wrong_Parameters);
     }
     $this->base64_auth = base64_encode($username . ':' . $client_key);
     //instantiate links
     $this->get_face_link = new Relation_Link($this->base64_auth, $server . '/api/', 'face/', 'GET');
     $this->post_face_link = new Relation_Link($this->base64_auth, $server . '/api/', 'face/', 'POST');
     $this->post_multiview_link = new Relation_Link($this->base64_auth, $server . '/api/', 'face_detail/', 'POST');
     $this->get_model_link = new Relation_Link($this->base64_auth, $server . '/api/', 'model/', 'GET');
     $this->post_model_link = new Relation_Link($this->base64_auth, $server . '/api/', 'model/', 'POST');
     $this->post_speaker_model_link = new Relation_Link($this->base64_auth, $server . '/api/', 'speaker/model/', 'POST');
     $this->put_model_link = new Relation_Link($this->base64_auth, $server . '/api/', 'model/', 'PUT');
     $this->delet_modelLink = new Relation_Link($this->base64_auth, $server . '/api/', 'model/', 'DELETE');
     $this->get_group_link = new Relation_Link($this->base64_auth, $server . '/api/', 'group/', 'GET');
     $this->post_group_link = new Relation_Link($this->base64_auth, $server . '/api/', 'group/', 'POST');
     $this->put_group_link = new Relation_Link($this->base64_auth, $server . '/api/', 'group/', 'PUT');
     $this->delete_group_link = new Relation_Link($this->base64_auth, $server . '/api/', 'group/', 'DELETE');
     $this->get_identity_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/', 'GET');
     $this->post_identity_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/', 'POST');
     $this->post_identity_face_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/face/', 'POST');
     $this->post_identity_speaker_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/speaker/', 'POST');
     $this->put_identity_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/', 'PUT');
     $this->delete_identity_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/', 'DELETE');
     $this->recognize_face_link = new Relation_Link($this->base64_auth, $server . '/api/', 'recognize/', 'POST');
     $this->recognize_speaker_link = new Relation_Link($this->base64_auth, $server . '/api/', 'speaker/recognize/', 'POST');
     $this->recognition_status = new Relation_Link($this->base64_auth, $server . '/api/', 'status/', 'GET');
     $this->get_usage_link = new Relation_Link($this->base64_auth, $server . '/api/', 'infos/', 'GET');
     $this->get_stream_link = new Relation_Link($this->base64_auth, $server . '/api/', 'stream/', 'GET');
     $this->post_stream_link = new Relation_Link($this->base64_auth, $server . '/api/', 'stream/', 'POST');
     $this->get_image_link = new Relation_Link($this->base64_auth, $server . '/api/', 'image/', 'GET');
     Server_Connection::get_instance()->user_agent = $user_agent;
 }
コード例 #27
0
/**
 * Get all the necessary details to directly upload a private file to S3
 * asynchronously with JavaScript.
 *
 * @param string $s3Bucket your bucket's name on s3.
 * @param string $region   the bucket's location, see here for details: http://amzn.to/1FtPG6r
 * @param string $acl      the visibility/permissions of your file, see details: http://amzn.to/18s9Gv7
 *
 * @return array ['url', 'inputs'] the forms url to s3 and any inputs the form will need.
 */
function getS3Details($s3Bucket, $region, $acl = 'private')
{
    // Options and Settings
    $algorithm = "AWS4-HMAC-SHA256";
    $service = "s3";
    $date = gmdate('Ymd\\THis\\Z');
    $shortDate = gmdate('Ymd');
    $requestType = "aws4_request";
    $expires = '86400';
    // 24 Hours
    $successStatus = '201';
    $url = '//' . $s3Bucket . '.' . $service . '-' . $region . '.amazonaws.com';
    // Step 1: Generate the Scope
    $scope = [AWS_ACCESS_KEY, $shortDate, $region, $service, $requestType];
    $credentials = implode('/', $scope);
    // Step 2: Making a Base64 Policy
    $policy = ['expiration' => gmdate('Y-m-d\\TG:i:s\\Z', strtotime('+6 hours')), 'conditions' => [['bucket' => $s3Bucket], ['acl' => $acl], ['starts-with', '$key', ''], ['starts-with', '$Content-Type', ''], ['success_action_status' => $successStatus], ['x-amz-credential' => $credentials], ['x-amz-algorithm' => $algorithm], ['x-amz-date' => $date], ['x-amz-expires' => $expires]]];
    $base64Policy = base64_encode(json_encode($policy));
    // Step 3: Signing your Request (Making a Signature)
    $dateKey = hash_hmac('sha256', $shortDate, 'AWS4' . AWS_SECRET, true);
    $dateRegionKey = hash_hmac('sha256', $region, $dateKey, true);
    $dateRegionServiceKey = hash_hmac('sha256', $service, $dateRegionKey, true);
    $signingKey = hash_hmac('sha256', $requestType, $dateRegionServiceKey, true);
    $signature = hash_hmac('sha256', $base64Policy, $signingKey);
    // Step 4: Build form inputs
    // This is the data that will get sent with the form to S3
    $inputs = ['Content-Type' => '', 'acl' => $acl, 'success_action_status' => $successStatus, 'policy' => $base64Policy, 'X-amz-credential' => $credentials, 'X-amz-algorithm' => $algorithm, 'X-amz-date' => $date, 'X-amz-expires' => $expires, 'X-amz-signature' => $signature];
    return compact('url', 'inputs');
}
コード例 #28
0
 public function beforeSave()
 {
     $encryptionMethod = "AES-256-CBC";
     //$this->data['MorphChartProblem']['name'] = openssl_encrypt($this->data['MorphChartProblem']['name'], $encryptionMethod, $this->getEncryptionKey(), false, "8werjsdfj00932sd");
     $this->data['MorphChartProblem']['name'] = trim(base64_encode(mcrypt_encrypt(MCRYPT_3DES, substr($this->getEncryptionKey(), 0, 24), $this->data['MorphChartProblem']['name'], MCRYPT_MODE_CBC, "8werjsdf")));
     return true;
 }
コード例 #29
-1
 function setAppConfig($approval = 'auto')
 {
     $this->client = new Google_Client();
     /* Set Retries */
     $this->client->setClassConfig('Google_Task_Runner', 'retries', 5);
     $this->userInfoService = new Google_Service_Oauth2($this->client);
     $this->googleDriveService = new Google_Service_Drive($this->client);
     $this->googleUrlshortenerService = new Google_Service_Urlshortener($this->client);
     if (!empty($this->settings['googledrive_app_client_id']) && !empty($this->settings['googledrive_app_client_secret'])) {
         $this->client->setClientId($this->settings['googledrive_app_client_id']);
         $this->client->setClientSecret($this->settings['googledrive_app_client_secret']);
     } else {
         $this->client->setClientId('538839470620-fvjmtsvik53h255bnu0qjmbr8kvd923i.apps.googleusercontent.com');
         $this->client->setClientSecret('UZ1I3I-D4rPhXpnE8T1ggGhE');
     }
     $this->client->setRedirectUri('http://www.florisdeleeuw.nl/use-your-drive/index.php');
     $this->client->setApprovalPrompt($approval);
     $this->client->setAccessType('offline');
     $this->client->setScopes(array('https://www.googleapis.com/auth/drive', 'https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/urlshortener'));
     $page = isset($_GET["page"]) ? '?page=' . $_GET["page"] : '';
     $location = get_admin_url(null, 'admin.php' . $page);
     $this->client->setState(strtr(base64_encode($location), '+/=', '-_~'));
     /* Logger */
     $this->client->setClassConfig('Google_Logger_File', array('file' => USEYOURDRIVE_CACHEDIR . '/log', 'mode' => 0640, 'lock' => true));
     $this->client->setClassConfig('Google_Logger_Abstract', array('level' => 'debug', 'log_format' => "[%datetime%] %level%: %message% %context%\n", 'date_format' => 'd/M/Y:H:i:s O', 'allow_newlines' => true));
     /* Uncomment the following line to log communcations.
      * The log is located in /cache/log
      */
     //$this->client->setLogger(new Google_Logger_File($this->client));
     return true;
 }
コード例 #30
-2
 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;
 }