class Settings {
private $settings;
private static $instance;
public static getInstance() {
if (!self::$instance) self::$instance = new self();
return self::$instance;
}
public function getSettings() {
return $this->settings;
}
private function __construct() {
$this->settings = ...
}
}
class Kernel {
protected $settings;
public function __construct() {
$this->settings = Settings::getInstance()->gteSettings();
}
}
будут иметь
$query = "SELECT command FROM id_donate WHERE id_game=? AND id=? LIMIT 1";
$stmt = $mysqli->prepare($query);
$id_game = 1;
$id = 1;
$stmt->bind_param("i", $id_game);
$stmt->bind_param("i", $id);
$stmt->execute();
$res = $stmt->get_result();
$answer = $res->fetch_assoc();
$command = $answer['command'];
$recepient = "index@mail.ru";
$sitename = "Butik";
$email= trim($_POST["email"]);
$message = "Телефон: $email";
$pagetitle = "Новая заявка с сайта \"$sitename\"";
mail($recepient, $pagetitle, $message, "Content-type: text/plain; charset=\"utf-8\"\n From: $recepient");
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
mail(
$email,
'Thank you!',
'Thank you! \r\n We will call you back now! Wait.', // ваш шаблон письма
"Content-type: text/plain; charset=\"utf-8\"\n From: $recepient"
);
}
class AdjacencyList
{
private static $tmpData;
public static function renderUnorderedList($rgData, \Closure $callback)
{
$html = '<ul>';
foreach ($rgData as $item) {
$children = $item['children'];
$item['children'] = !empty($children);
$html .= '<li>';
ob_start();
$callback($item);
$html .= ob_get_clean();
if (!empty($children)) {
$html .= self::renderUnorderedList($children, $callback);
}
$html .= '</li>';
}
$html .= '</ul>';
return $html;
}
public static function buildTree($rgData, $start = 0, $idKey = 'id', $idParentKey = 'parent_id')
{
self::$tmpData = self::assignKeys($rgData);
$result = self::buildTreeRecursive($start, $idKey, $idParentKey);
return $result;
}
private static function buildTreeRecursive($start, $idKey, $idParentKey)
{
$rgResult = array();
foreach (self::$tmpData as $item) {
if ($item[$idParentKey] == $start) {
$item['children'] = self::buildTreeRecursive($item[$idKey], $idKey, $idParentKey);
$rgResult[] = $item;
}
}
return empty($rgResult) ? null : $rgResult;
}
private static function assignKeys($rgData, $key = 'id')
{
$tmp = array();
foreach ($rgData as $item) {
$tmp[$item[$key]] = $item;
}
return $tmp;
}
}
$fieldNames = [
"lastname",
"name",
"middlename",
"birthday",
"driver-serie",
"driver-number",
"passport-serie",
"passport-number",
"phone-number",
"email",
"lastname1",
"name1",
"middlename1",
"driver-serie1",
"driver-number1",
"passport-serie1",
"passport-number1"
];
$fileds = [];
// всё, добавляйте полей, сколько хотите...
foreach ($fieldNames as $fName) {
$fields[$fname] = htmlspecialchars($_POST[$fname]);
}
$mes = "Сообщение с сайта.\n
Имя отправителя: {$field['lastname']}, {$field['name']}, {$field['middlename']}
Дата рождения: {$field['birthday']}
...
";
foreach ($employee as $value) {
echo ' <div class="new-form" data-employee-id="'.$value['id_employee'].'">
<input type="text" disabled value="'.$value['first_name'].'">
<input type="text" disabled value="'.$value['second_name'].'">
<input type="text" disabled value="'.$value['middle_name'].'">
<select name="list-position" id="list-position">';
foreach ($positions as $val) {
echo '<option value="'.$val['id_position'].'">'.$val['position'].'</option>';
}
// echo забыл
echo '</select>
<input type="text" disabled value="'.$value['position'].'">
<input type="text" disabled value="'.$value['salary'].'">
<button class="change-employee" data-id="'.$id.'">Изменить</button>
<button id="js-save-change-employee" class="save-change-employee hide" data-id="'.$id.'">Сохранить изменения</button>
</div>';
}
<?php foreach ($employee as $value) { ?>
<div class="new-form" data-employee-id="<?= $value['id_employee'] ?>">
<input type="text" disabled value="<?= $value['first_name'] ?>">
<input type="text" disabled value="<?= $value['second_name'] ?>">
<input type="text" disabled value="<?= $value['middle_name'] ?>">
<select name="list-position" id="list-position">';
<?php foreach ($positions as $val) { ?>
<option value="<?= $val['id_position'] ?>"><?= $val['position'] ?></option>
<?php } ?>
</select>
<input type="text" disabled value="<?= $value['position'] ?>">
<input type="text" disabled value="<?= $value['salary'] ?>">
<button class="change-employee" data-id="<?= $id ?>">Изменить</button>
<button id="js-save-change-employee" class="save-change-employee hide" data-id="<?= $id ?>">Сохранить изменения</button>
</div>
<?php } ?>
$message = 'У юзера выпало %s, а у компьютера %s. %s';
$resultMessages = ['Выигрыш компьтера', 'Ничья', 'Выигрыш игрока'];
$userDice = mt_rand(1,6);
$compDice = mt_rand(1,6);
$diff = $userDice - $compDice;
$result = ($diff ? $diff / abs($diff) : $diff) + 1;
printf($message, $userDice, $compDice, $resultMessages[$result]);
$message = 'У юзера выпало %s, а у компьютера %s. %s';
$resultMessages = ['Выигрыш компьтера', 'Ничья', 'Выигрыш игрока'];
$userDice = mt_rand(1,6);
$compDice = mt_rand(1,6);
printf($message, $userDice, $compDice, $resultMessages[($userDice <=> $compDice) + 1]);
по словам крутого разраба, ПРОЩЕ сделать самому
Где лучше указывать url, на который будет отправляться форма