Exemplo n.º 1
0
 public function insert($fields = null)
 {
     $path = \Yii::getAlias(\cs\Widget\FileUploadMany\FileUploadMany::$uploadDirectory);
     foreach ($this->file as $file) {
         $filePath = $path . DIRECTORY_SEPARATOR . $file[0];
         \cs\services\VarDumper::dump($filePath);
     }
 }
 public function actionTest2()
 {
     $access_token = '410011473018906.8B0BD62ED86765ED98DE3B5EBE22348AC68900066E8EAC7093EB9B8A831D00DAC6556C6B40BA284F2B5391A5EEBCA47C9F755BC4A713584F71D8470D8D660CEDA8A455E290868CC1817ED867D350B5C1074A37CE62F662D94025D799638A30034651FBF656A74BBD003FC402E77BAD140883D414C77B4228BC7A7940B9833164';
     $api = new API($access_token);
     // get account info
     $acount_info = $api->accountInfo();
     VarDumper::dump($acount_info);
 }
Exemplo n.º 3
0
 public static function sendRequest($url, $options = [], $access_token = null)
 {
     $curl = curl_init($url);
     curl_setopt($curl, CURLOPT_USERAGENT, 'Yandex.Money.SDK/PHP');
     curl_setopt($curl, CURLOPT_POST, 1);
     $query = http_build_query($options);
     curl_setopt($curl, CURLOPT_POSTFIELDS, $query);
     curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl, CURLOPT_HEADER, 0);
     //curl_setopt($curl, CURLOPT_VERBOSE, 1);
     //        curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, true);
     //        curl_setopt ($curl, CURLOPT_SSL_VERIFYHOST, 2);
     //        curl_setopt($curl, CURLOPT_CAINFO, __DIR__ . "/cacert.pem");
     $body = curl_exec($curl);
     $result = new \StdClass();
     $result->status_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     $result->body = $body;
     curl_close($curl);
     \cs\services\VarDumper::dump($result);
 }
Exemplo n.º 4
0
 /**
  * Импортирует данные с Finam в таблицу курсов
  *
  * @param int    $stock_id
  * @param string $start             дата 'yyyy-mm-dd'
  * @param string $end               дата 'yyyy-mm-dd'
  * @param bool   $isReplaceExisting Заменять уже имеющиеся данные
  *                                  true - если в таблице уже есть курс на эту дату то он будет перезатерт
  *                                  false - если в таблице уже есть курс на эту дату то он сохранится
  *
  * @throws \yii\base\InvalidConfigException
  */
 public static function importData($stock_id, $start, $end, $isReplaceExisting = false)
 {
     $row = Stock::find($stock_id)->getFields();
     $data = ['params' => ['market' => $row['finam_market'], 'em' => $row['finam_em'], 'code' => $row['finam_code']]];
     $importer = new \app\service\DadaImporter\Finam($data);
     $data = $importer->importCandels($start, $end);
     VarDumper::dump($data);
     $dateArrayRows = StockKurs::query(['between', 'date', $start, $end])->select(['date'])->andWhere(['stock_id' => $stock_id])->column();
     $insert = [];
     $update = [];
     foreach ($data as $row) {
         if (in_array($row['date'], $dateArrayRows)) {
             $update[$row['date']] = $row['kurs'];
         } else {
             $insert[] = [$stock_id, $row['date'], $row['kurs']];
         }
     }
     StockKurs::batchInsert(['stock_id', 'date', 'kurs'], $insert);
     if ($isReplaceExisting) {
         foreach ($update as $date => $kurs) {
             (new Query())->createCommand()->update(StockKurs::TABLE, ['kurs' => $kurs], ['date' => $date, 'stock_id' => $stock_id])->execute();
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Показывает значение в кеше
  */
 public function actionCache_show()
 {
     Yii::$app->session->open();
     VarDumper::dump(Yii::$app->cache->get(Yii::$app->session->getId() . '/maya'));
 }
Exemplo n.º 6
0
 public function actionTest()
 {
     VarDumper::dump($_SERVER['SERVER_NAME']);
 }
Exemplo n.º 7
0
 public function auth22()
 {
     $defaultParams = ['client_id' => $this->clientId, 'response_type' => 'code', 'redirect_uri' => 'http://c.galaxysss.ru/yandexMoney'];
     if (!empty($this->scope)) {
         $defaultParams['scope'] = $this->scope;
     }
     $params = $this->sendRequest2('POST', $this->authUrl, $defaultParams, []);
     $url = new Url($params[1]['redirect_url']);
     $code = $url->getParam('requestid');
     $defaultParams = ['code' => $code, 'client_id' => $this->clientId, 'grant_type' => 'authorization_code', 'redirect_uri' => 'http://c.galaxysss.ru/yandexMoney'];
     $params = $this->sendRequest2('POST', $this->tokenUrl, $defaultParams, []);
     \cs\services\VarDumper::dump($params);
 }
Exemplo n.º 8
0
 public function actionCalc()
 {
     $blue = CalculatingProbability::initStock(1, 2);
     $red = CalculatingProbability::initStock(1, 1);
     VarDumper::dump([$blue->calc(), $red->calc()]);
 }
Exemplo n.º 9
0
 /**
  * Runs the action.
  */
 public function run()
 {
     $clientId = 'yandex_money';
     /* @var $collection \yii\authclient\Collection */
     $collection = Yii::$app->get($this->clientCollection);
     if (!$collection->hasClient($clientId)) {
         throw new NotFoundHttpException("Unknown auth client '{$clientId}'");
     }
     $client = $collection->getClient($clientId);
     $defaultParams = ['client_id' => $client->clientId, 'response_type' => 'code', 'redirect_uri' => 'http://c.galaxysss.ru/yandexMoney'];
     if (!empty($this->scope)) {
         $defaultParams['scope'] = $client->scope;
     }
     VarDumper::dump($client->sendRequest('POST', $client->authUrl, $defaultParams, []));
 }
Exemplo n.º 10
0
 /**
  * Вызов возможен как render($view, $params)
  * или как render($params)
  * тогда $view = название функции action
  * например если вызов произошел из метода actionOrders то $view = 'orders'
  *
  * @param string|array $view   шаблон или параметры шаблона
  * @param array        $params параметры шаблона если $view = шаблон, иначе не должен указываться
  *
  * @return string = \yii\base\Controller::render()
  */
 public function render($view = '', $params = [])
 {
     if (is_array($view)) {
         $params = $view;
         $view = strtolower(str_replace('action', '', debug_backtrace(2)[1]['function']));
     } else {
         if ($view == '') {
             $params = [];
             $view = strtolower(str_replace('action', '', debug_backtrace(2)[1]['function']));
         } else {
             if ($view == '.tpl') {
                 $view = strtolower(str_replace('action', '', debug_backtrace(2)[1]['function'])) . '.tpl';
             }
         }
     }
     if (StringHelper::endsWith(strtolower($view), '.tpl')) {
         $this->layout .= '.tpl';
     }
     if (self::getParam('_view', '') != '') {
         \cs\services\VarDumper::dump($params, 10);
         return '';
     }
     return parent::render($view, $params);
 }