<?php foreach ($fields as $field): ?>
<?= Html::activeHiddenInput($model, "[$field->id]id_field", ['value' => $field->id]) ?>
<?= $form->field($model, "[$field->id]data")->textInput(['value' => $model->data]) ?>
<?php endforeach; ?>
Field_Data[1][id_field] = 1
Field_Data[1][data] = "значение поля 1"
Field_Data[2][id_field] = 2
Field_Data[2][data] = "значение поля 2"
if (Yii::$app->request->post('Field_Data')) {
foreach (Yii::$app->request->post('Field_Data') as $fieldData) {
$model = new FieldData();
$model->id_field = $fieldData['id_field'];
$model->data = $fieldData['data'];
if ($model->validate()) {
$model->save();
}
}
}
server {
listen 443 ssl;
server_name your-domain.com;
ssl_certificate /etc/nginx/ssl/your_domain.crt;
ssl_certificate_key /etc/nginx/ssl/your_domain.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
# Прокси для WebSocket
location /wss/ {
proxy_pass http://localhost:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location / {
proxy_pass http://localhost:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
class ProductAmount
{
function __construct($array = array()) {
...
}
function getOfers($items = []) {
...
return $this;
}
function getProfuctStore($inListStore = 'N') {
...
return $this;
}
function setListStore($inListStore = 'Y') {
...
return $this;
}
}
$obj = new ProductAmount();
$res = $obj->getOfers([229411])->getProfuctStore('Y')->setListStore('Y');
<form action="upload.php" method="post" enctype="multipart/form-data">
<label for="file">Выберите изображение:</label>
<input type="file" name="file" id="file" required>
<button type="submit">Загрузить</button>
</form>
<?php
$target_dir = "img/";
$target_file = $target_dir . basename($_FILES["file"]["name"]);
$imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
$check = getimagesize($_FILES["file"]["tmp_name"]);
if($check !== false) {
if (file_exists($target_file)) {
echo "Файл уже существует.";
} else {
if ($_FILES["file"]["size"] > 2000000) {
echo "Файл слишком большой.";
} else {
$allowed_types = array('jpg', 'jpeg', 'png', 'gif');
if (in_array($imageFileType, $allowed_types)) {
move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)
}
}
}
}
?>
$file = 'deal_updates.txt';
$input = file_get_contents('php://input');
$data = json_decode($input, true);
if (isset($data['event']) && $data['event'] === 'ONCRMDEALUPDATE') {
$dealId = $data['data']['FIELDS']['ID'];
$newStatus = $data['data']['FIELDS']['STATUS_ID'];
$updateDate = date('Y-m-d H:i:s');
$log = "Deal ID: $dealId | New Status: $newStatus | Updated at: $updateDate\n";
file_put_contents($file, $log, FILE_APPEND);
}
http_response_code(200);
echo 'OK';
$array = [];
$requiredKeys = ['id', 'name', 'photo'];
foreach ($babysitters as $babysitter) {
$babysitterData = new \stdClass;
foreach ($requiredKeys as => $key) {
$babysitterData->${'babysitter_' . $key} = $babysitter->$key;
}
$array[] = $babysitterData;
}
$xmlContent = '<?xml version="1.0" encoding="UTF-8"?><message>Пример сообщения</message>';
$xmlBytes = unpack('C*', $xmlContent);
$byteString = implode(array_map("chr", $xmlBytes));
$url = 'https://edi.kontur.ru/V1/Messages/SendMessage';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/octet-stream',
...
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $byteString);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Ошибка cURL: ' . curl_error($ch);
} else {
echo 'Ответ сервера: ' . $response;
}
curl_close($ch);
$("#modal").off('submit').on('submit', function (e) {
e.preventDefault();
var form_data = $(this).serialize();
$.ajax({
type: "POST",
url: "user/add.php",
data: form_data,
success: function (html) {
document.getElementById("shadow").style.display = "none";
document.getElementById("modal").style.display = "none";
$('#modal').trigger('reset');
$("#main").append(html);
}
});
});
require "../database/Task.php";
if (isset($_POST['title']) && isset($_POST['description'])) {
$task_mess = new Task;
$task_mess->add_task($_POST['title'], $_POST['description']);
$new_task = $task_mess->get_last_task();
echo "<div class='task'>
<h3>{$new_task['title']}</h3>
<p>{$new_task['description']}</p>
</div>";
}