$config['dataProvider']->pagination->pageSize = 200;
$config['dataProvider']->refresh();
$key = 'password to (en/de)crypt';
$string = ' {login:"user_test", password:"12311231!"} '; // note the spaces
$encrypted = "t0izCc6wCMaoOFbTnjrUCaVzXtqzv0O2812Yv9DT7p19llSuu4eFV6ha4ukvFeYCYr31LAVHYo5BaUzuCBNkcA==";
$data = base64_decode($encrypted);
$iv = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
$decrypted = rtrim(
mcrypt_decrypt(
MCRYPT_RIJNDAEL_128,
hash('sha256', $key, true),
substr($data, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC)),
MCRYPT_MODE_CBC,
$iv
),
"\0"
);
echo 'Encrypted:' . "\n";
var_dump($encrypted);
echo "\n";
echo 'Decrypted:' . "\n";
var_dump($decrypted);
<?php
use yii\authclient\widgets\AuthChoice;
$icons_id = [
'vkontakte' => 1,
'facebook' => 2,
'tw' => 3,
'mr' => 4,
'odnoklassniki' => 5
];
$authAuthChoice = AuthChoice::begin([
'baseAuthUrl' => ['auth/social'],
]);?>
<ul class="soc-list">
<?php foreach ($authAuthChoice->getClients() as $client): ?>
<li>
<a data-popup-width="500" data-popup-height="430"
href="<?= $authAuthChoice->createClientUrl($client)?>"><i class="ico ico-soc-<?=$icons_id[$client->getId()]?>"></i></a>
</li>
<?php endforeach; ?>
</ul>
<?php AuthChoice::end(); ?>
<?php
namespace app\components\authclient\clients;
use yii\authclient\OAuth2;
/**
* Mailru allows authentication via Mail.ru OAuth.
*
* In order to use Mail.ru OAuth you must register your application
* at <http://api.mail.ru/sites/my/add>.
*
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'mailru' => [
* 'class' => 'yii\authclient\clients\Mailru',
* 'clientId' => 'mailru_app_id',
* 'clientSecret' => 'mailru_app_secret_key',
* ],
* ],
* ]
* ...
* ]
* ~~~
*
* @see http://api.mail.ru/sites/my/add
* @see http://api.mail.ru/docs/guides/oauth/sites/
* @see http://api.mail.ru/docs/reference/js/users.getInfo/
*
* @author Kazan1000 <kazan1000@gmail.com>
*
*/
class Mailru extends OAuth2 {
/**
* @inheritdoc
*/
public $authUrl = 'https://connect.mail.ru/oauth/authorize';
/**
* @inheritdoc
*/
public $tokenUrl = 'https://connect.mail.ru/oauth/token';
/**
* @inheritdoc
*/
public $apiBaseUrl = 'http://www.appsmail.ru/platform/api';
/**
* @inheritdoc
*/
protected function initUserAttributes() {
return $this->api('users.getInfo', 'GET');
}
public function api($apiSubUrl, $method = 'GET', array $params = [ ], array $headers = [ ]) {
$params['method'] = $apiSubUrl;
return parent::api($this->apiBaseUrl, $method, $params, $headers);
}
protected function determineContentTypeByRaw($rawContent) {
//determine json array's too
if (preg_match('/^\\[.*\\]$/is', $rawContent)) {
return self::CONTENT_TYPE_JSON;
}
return parent::determineContentTypeByRaw($rawContent);
}
/**
* @inheritdoc
*/
protected function apiInternal($accessToken, $url, $method, array $params, array $headers) {
$params['format'] = 'json';
$params['secure'] = 1;
$params['app_id'] = $this->clientId;
$token = $accessToken->getToken();
$params['session_key'] = $token;
//sign up params - http://api.mail.ru/docs/guides/restapi/#server
ksort($params);
$str = '';
foreach ($params as $key => $value) {
$str .= "$key=$value";
}
$params['sig'] = md5($str . $this->clientSecret);
return $this->sendRequest($method, $url, $params, $headers);
}
/**
* @inheritdoc
*/
protected function defaultName() {
return 'mailru';
}
/**
* @inheritdoc
*/
protected function defaultTitle() {
return 'Mail.ru';
}
/**
* @inheritdoc
*/
protected function defaultNormalizeUserAttributeMap() {
return [
'id' => [
0,
'uid'
],
];
}
}
<?php
namespace app\components\authclient\clients;
use yii\authclient\OAuth2;
/**
* Class Odnoklassniki
* @package app\components\authclient\clients
* Example application configuration:
*
* ~~~
* 'components' => [
* 'authClientCollection' => [
* 'class' => 'yii\authclient\Collection',
* 'clients' => [
* 'odnoklassniki' => [
* 'class' => 'yii\authclient\clients\odnoklassniki',
* 'clientId' => 'app_client_id',
* 'clientSecret' => 'application_client_secret',
* 'application_public_key' => 'application_public_key',
* 'scope' => 'VALUABLE_ACCESS'
* ],
* ],
* ]
* ...
* ]
*/
class Odnoklassniki extends OAuth2
{
/**
* @inheritdoc
*/
public $authUrl = 'http://www.odnoklassniki.ru/oauth/authorize';
/**
* @inheritdoc
*/
public $tokenUrl = 'http://api.odnoklassniki.ru/oauth/token.do';
/**
* @inheritdoc
*/
public $apiBaseUrl = 'http://api.odnoklassniki.ru/fb.do';
public $application_public_key;
/**
* @inheritdoc
*/
protected function initUserAttributes()
{
return $this->api('','GET',[
'method' => 'users.getCurrentUser',
'format' => 'JSON',
'application_key' => $this->application_public_key,
'client_id' => $this->clientId,
]);
}
/**
* @inheritdoc
*/
protected function apiInternal($accessToken, $url, $method, array $params, array $headers)
{
$access_token = $accessToken->getToken();
if (count($params)) {
$param_str = '';
ksort($params);
foreach ($params as $k => $v)
{
$param_str .= $k . '=' . $v;
}
$params['sig'] = md5($param_str . md5($access_token . $this->clientSecret));
}
$params['access_token'] = $access_token;
return $this->sendRequest($method, trim($url,'/'), $params, $headers);
}
/**
* @inheritdoc
*/
protected function defaultName()
{
return 'odnoklassniki';
}
/**
* @inheritdoc
*/
protected function defaultTitle()
{
return 'Odnoklassniki';
}
/**
* @inheritdoc
*/
protected function defaultNormalizeUserAttributeMap()
{
return [
'id' => 'uid'
];
}
}
//...
'authClientCollection' => [
'class' => 'yii\authclient\Collection',
'clients' => [
'vkontakte' => [
'class' => 'yii\authclient\clients\VKontakte',
'clientId' => '',
'clientSecret' => '',
'scope' => 'friends,email,offline',
],
'facebook' => [
'class' => 'yii\authclient\clients\Facebook',
'clientId' => '',
'clientSecret' => '',
],
'odnoklassniki' => [
'class' => 'app\components\authclient\clients\Odnoklassniki',
'clientId' => '',
'clientSecret' => '',
'application_public_key' => '',
'scope' => 'VALUABLE_ACCESS'
],
],
],
<?php
/* PUT data comes in on the stdin stream */
$putdata = fopen("php://input", "r");
/* Open a file for writing */
$fp = fopen("myputfile.ext", "w");
/* Read the data 1 KB at a time
and write to the file */
while ($data = fread($putdata, 1024))
fwrite($fp, $data);
/* Close the streams */
fclose($fp);
fclose($putdata);
if(move_uploaded_file($_FILES["VIDEO']["file"]["tmp_name"], путь + имя куда сохранить)){
echo "upload success";
}
выход только если создать свой autocomplete с extends AutoComplete
Если у вас много select: function() { ... }
Зарегистрируйте ее так