Skip to content

Instantly share code, notes, and snippets.

View fedorovanton's full-sized avatar
🏡
I work remotely from home

Anton Fedorov fedorovanton

🏡
I work remotely from home
  • Russia
View GitHub Profile
@fedorovanton
fedorovanton / gist:0310aafb52b707720201a80ffd44a82b
Created October 9, 2018 08:00
Асинхронное добавление/удаление записей
/**
* Отправка ajax на удаление записи с id из таблицы mailing_object + удаление строчки tr
* @param id
*/
function removeRecord(id) {
var data = {
id: id
};
$.ajax({
select.form-control {
outline: none;
-webkit-appearance: none;
border-radius: 0;
}
@fedorovanton
fedorovanton / gist:a9c59e686d7477b47393fef218761137
Last active August 17, 2018 08:07
Отправка данных ActiveForm с помощью Ajax (с пост-оберткой)
Контроллер ClientController:
============================
public function actionAdd()
{
$model = new AddClientOwnerForm();
if(Yii::$app->request->isAjax){
if($model->load(Yii::$app->request->post())) {
// ... ваш обработчик данных...
if ($model->save()) {
<?php
define('API_URL', 'https://api.telegram.org/bot');
define('BOT_TOKEN', '123456789:asdsadsadasdasdsadsadasdasd');
define('CHAT_ID_ANTON', '1234567');
function botSendMessage($parameters){
$url = API_URL . BOT_TOKEN . '/sendMessage?' . http_build_query($parameters);
file_get_contents($url);
<?php
/*
Use the built-in password hashing functions to hash and compare passwords.
Hashing is the standard way of protecting a user's password before it's stored in a database. Many common hashing algorithms like md5 and even sha1 are unsafe for storing passwords, because hackers can easily crack passwords hashed using those algorithms.
PHP provides a built-in password hashing library that uses the bcrypt algorithm, currently considered the best algorithm for password hashing.
Хеширование пароля и проверка хеша
*/
// Hash the password. $hashedPassword will be a 60-character string.
$hashedPassword = password_hash('my super cool password', PASSWORD_DEFAULT);