$date = '2024-05-20 12:45:53';
$sql = "SELECT * FROM your_table WHERE your_datetime_column < ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param('s', $date);
$stmt->execute();
$result = $stmt->get_result();
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
echo "id: " . $row["id"] . " - Дата: " . $row["your_datetime_column"] . "<br>";
}
} else {
echo "Пусто";
}
// vendor/irazasyed/telegram-bot-sdk/src/TelegramClient.php
const BASE_BOT_URL = 'http://127.0.0.1:8081/bot';
[supervisord]
environment=TELEGRAM_API_ID="2*****89",TELEGRAM_API_HASH="dc8******c34"
[program:tgapi]
command=/usr/local/bin/telegram-bot-api -u root -g www-data --local --max-webhook-connections=3 --http-stat-ip-address=127.0.0.1 --http-stat-port=8082
directory=/var/tgapi
user=root
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
numprocs=1
Но после вывода этого массива через 180 сек возникает завершение работы скрипта
<?php
$x = empty($_GET["x"])?1:$_GET["x"];
file_put_contents("mylog.txt", $x."\n", FILE_APPEND);
if($x>5) exit();
$x+=1;
$ch = curl_init("http://mserver.example.com/script.php?x=".$x);
curl_exec($ch);
curl_close($ch);
<?php
class SqliteStore {
protected $db;
public function __construct($tableName, $filePath = 'db.sqlite') {
$this->db = new SQLite3($filePath);
$this->tableName = $this->db->escapeString($tableName);
if (is_numeric($tableName[0])) {
$details = sprintf(
"sqlite will choke on table names that start w/ a number. yours starts w/ '%s'",
$tableName[0]
);
throw new Exception($details);
}
//wrap in try/catch & ignore warnings as workaround to lack of 'if not exists' in sqlite version
try {
$sql = "create table $tableName ( key text primary key, value text, tm INT )";
@$this->db->query( $sql );
} catch ( Exception $e ) {
// var_dump($e);
}
}
public function get($key, $defvalue = '') {
$sql = sprintf(
"SELECT value FROM %s WHERE key = '%s';",
$this->tableName, $key
);
$result = $this->db->query($sql)->fetchArray(SQLITE3_ASSOC);
if ($result) {
$result = $result['value'];
} else { $result = $defvalue; }
return $result;
}
public function set($key, $value){
$time = time();
$sql = sprintf(
"REPLACE INTO %s (key, value, tm) VALUES ('%s', '%s', %d);",
$this->tableName, $this->db->escapeString($key), $this->db->escapeString($value), $time
);
//allow exceptions to bubble up
$this->db->exec($sql);
}
public function delete($key){
$sql = sprintf(
"DELETE FROM %s WHERE key = '%s';",
$this->tableName, $this->db->escapeString($key)
);
//allow exceptions to bubble up
$this->db->exec($sql);
}
public function deleteOld($seconds){
$time = time();
$sql = sprintf(
"DELETE FROM %s WHERE (%d - tm > %d);",
$this->tableName, $time, $seconds
);
//allow exceptions to bubble up
$this->db->exec($sql);
}
public function delete_old($seconds){
return $this->deleteOld($seconds);
}
}
$ss = new SqliteStore('tg');
$data = json_decode(file_get_contents('php://input'), TRUE);
$message = trim($data["message"]["text"]);
$chat_id = $data["chat"]["id"];
if ($message === '/start') {
$method = 'sendMessage';
$send_data = [
'text' => "Привет! Я бот для анализа активности подписчиков в каналах, чатах и группах."
];
}
# Проверяем, вводит ли пользователь ссылку.
elseif (strpos($message, 'http') === 0) {
$ss->set('saveChannelLink'.$chat_id, $message);
$method = 'sendMessage';
$send_data = [
'text' => "Отлично! Отправь мне число:"
];
}
elseif (is_numeric($message)) {
$ss->set('saveChannelNumber'.$chat_id, $message);
$method = 'sendMessage';
$saveChannelLink = $ss->get('saveChannelLink'.$chat_id);
$saveChannelNumber = $ss->get('saveChannelNumber'.$chat_id);
$send_data = [
'text' => "Отлично! Ссылка: " . $saveChannelLink . "\nЧисло: " . $saveChannelNumber
];
echo json_encode($send_data);
<video></video>
var videoElement = document.querySelector('video');
getStream().then(getDevices).then(gotDevices);
function getDevices() {
// AFAICT in Safari this only gets default devices until gUM is called :/
return navigator.mediaDevices.enumerateDevices();
}
function gotDevices(deviceInfos) {
window.deviceInfos = deviceInfos; // make available to console
console.log('Available input and output devices:', deviceInfos);
}
window.setTimeout(getStream, 10);
}
function getStream() {
if (window.stream) {
window.stream.getTracks().forEach(track => {
track.stop();
});
}
const videoSource = videoSelect.value;
const constraints = {
video: {
deviceId: videoSource ? {
exact: videoSource
} : undefined
}
};
return navigator.mediaDevices.getUserMedia(constraints).
then(gotStream).catch(handleError);
}
function gotStream(stream) {
window.stream = stream; // make stream available to console
if ('srcObject' in videoElement) {
videoElement.srcObject = stream;
} else {
videoElement.src = URL.createObjectURL(stream);
}
}
function handleError(error) {
console.error('Error: ', error);
}
function getImgUrl() {
let el = videoElement;
let canvas = document.createElement('canvas');
canvas.width = el.videoWidth;
canvas.height = el.videoHeight;
canvas.style.display = 'none';
document.body.appendChild(canvas);
canvas.getContext('2d').drawImage(el, 0, 0, canvas.width, canvas.height);
let cu = canvas.toDataURL();
document.body.removeChild(canvas);
return cu;
}
$mail = $_POST['mail'];
$mail = trim($mail);
$mail = $link->real_escape_string($mail);
$info_user = mysqli_fetch_assoc($link->query("SELECT * FROM `user` WHERE mail = $mail"));
if($info_user) {
echo '1';
}
else {
echo '2';
}
$mail = $_POST['mail'];
$mail = trim($mail);
$stmt = $link->prepare("SELECT * FROM user WHERE mail = ?");
$stmt->bind_param("s", $mail); // here we can use only a variable
$stmt->execute();
$result = $stmt->get_result();
$info_user = $result->fetch_all(MYSQLI_ASSOC);
if($info_user) {
echo '1';
}
else {
echo '2';
}