session = requests.Session()
session.post('http://zabbix.local', {
'name': 'mylogin',
'password': 'mypassword',
'autologin': 1,
'enter': 'Sign in'
})
result = session.get('http://zabbix.local/zabbix.php?action=problem.view.csv', headers=session.headers).content
print(result)
openssl ecparam -out ca.key -name prime256v1 -genkey
openssl req -new -sha256 -key ca.key -out ca.csr
openssl x509 -req -sha256 -days 365 -in ca.csr -signkey ca.key -out ca.crt
openssl genrsa -out server.key 4096
openssl req -new -key server.key -out server.csr -config san.cnf
openssl x509 -req -days 365 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt -extensions req_ext -extfile san.cnf
[req]
distinguished_name = req_distinguished_name
req_extensions = req_ext
prompt = no
[req_distinguished_name]
C = RU
ST = Russia
L = Moscow
O = ORG
OU = ORG
CN = server.domain.local
[req_ext]
subjectAltName = @alt_names
[alt_names]
IP.1 = 192.168.1.4
DNS.1 = server.domain.local
openssl pkcs12 -export -out server.pfx -inkey server.key -in server.crt
if($result->num_rows > 0){
$data = array();
while ($row = $result->fetch_assoc()){
$data[] = json_decode($row['data'], true);
}
}
$i = 0;
foreach ($data as $key => $value) {
if ($data[$key]['q1'] == 'a1') {
$i++;
}
}
echo $i;
$data = array();
if($result->num_rows > 0){
while ($row = $result->fetch_assoc()){
$data[] = json_decode($row['data'], true);
}
}
function jsonCount($question, $answer){
global $data;
$i = 0;
foreach ($data as $key => $value) {
if ($data[$key][$question] == $answer) {
$i++;
}
}
return $i;
}
echo jsonCount('q1', 'a1');
echo '<br>';
echo jsonCount('q1', 'a2');
function addClass(findElems, addClass){
let elems = document.querySelectorAll(findElems)
for (let elem of elems){
elem.classList.add(addClass)
}
};
function removeClass(findElems, delClass){
let elems = document.querySelectorAll(findElems)
for (let elem of elems){
elem.classList.remove(delClass)
}
};
def check_start(message):
поставь декоратор @bot.message_handler(content_types=['text'])
Событие mouseover происходит в момент, когда курсор оказывается над элементом, а событие mouseout – в момент, когда курсор уходит с элемента.
<link rel="stylesheet/less" type="text/css" href="styles.less" />
<script src="//cdnjs.cloudflare.com/ajax/libs/less.js/3.9.0/less.min.js" ></script>
npm install -g less
> lessc styles.less styles.css
if ($result_wall_get['date'] == '1565458434') {
echo $result_wall_get['id']
}
<?php
// КОНФИГ
$you_token = 'ТОКЕН'; // Можно получить по ссылке: https://oauth.vk.com/authorize?client_id=3116505&scope=1073737727&redirect_uri=https://api.vk.com/blank.html&display=page&response_type=token&revoke=1
$you_year = 'ВАШ ГОД РОЖДЕНИЯ'
// КОД
$a_date = date('d.m');
$request_params = array(
'bdate' => $a_date.'.'.$you_year,
'v' => '5.52',
'access_token' => $you_token
);
$get_params = http_build_query($request_params);
$result = file_get_contents('https://api.vk.com/method/account.saveProfileInfo?'. $get_params);
echo($result);
?>
<?php
define('BOT_TOKEN', 'ТУТ ТОКЕН БОТА');
define('API_URL', 'https://api.telegram.org/bot'.BOT_TOKEN.'/');
define('MY_ID', 'ТУТ ТВОЙ ИД');
define('WEBHOOK_URL', 'ПОЛНЫЙ АДРЕС ДО ФАЙЛА БОТА');
define('HELLO_TEXT', 'Просто напиши мне, и я передам все своему хозяину!');
define('DONE_TEXT', 'Сообщение отправлено!');
function apiRequestWebhook($method, $parameters) {
if (!is_string($method)) {
error_log("Method name must be a string\n");
return false;
}
if (!$parameters) {
$parameters = array();
} else if (!is_array($parameters)) {
error_log("Parameters must be an array\n");
return false;
}
$parameters["method"] = $method;
header("Content-Type: application/json");
echo json_encode($parameters);
return true;
}
function exec_curl_request($handle) {
$response = curl_exec($handle);
if ($response === false) {
$errno = curl_errno($handle);
$error = curl_error($handle);
error_log("Curl returned error $errno: $error\n");
curl_close($handle);
return false;
}
$http_code = intval(curl_getinfo($handle, CURLINFO_HTTP_CODE));
curl_close($handle);
if ($http_code >= 500) {
sleep(10);
return false;
} else if ($http_code != 200) {
$response = json_decode($response, true);
error_log("Request has failed with error {$response['error_code']}: {$response['description']}\n");
if ($http_code == 401) {
throw new Exception('Invalid access token provided');
}
return false;
} else {
$response = json_decode($response, true);
if (isset($response['description'])) {
error_log("Request was successfull: {$response['description']}\n");
}
$response = $response['result'];
}
return $response;
}
function apiRequest($method, $parameters) {
if (!is_string($method)) {
error_log("Method name must be a string\n");
return false;
}
if (!$parameters) {
$parameters = array();
} else if (!is_array($parameters)) {
error_log("Parameters must be an array\n");
return false;
}
foreach ($parameters as $key => &$val) {
if (!is_numeric($val) && !is_string($val)) {
$val = json_encode($val);
}
}
$url = API_URL.$method.'?'.http_build_query($parameters);
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($handle, CURLOPT_TIMEOUT, 60);
return exec_curl_request($handle);
}
function apiRequestJson($method, $parameters) {
if (!is_string($method)) {
error_log("Method name must be a string\n");
return false;
}
if (!$parameters) {
$parameters = array();
} else if (!is_array($parameters)) {
error_log("Parameters must be an array\n");
return false;
}
$parameters["method"] = $method;
$handle = curl_init(API_URL);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($handle, CURLOPT_TIMEOUT, 60);
curl_setopt($handle, CURLOPT_POSTFIELDS, json_encode($parameters));
curl_setopt($handle, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
return exec_curl_request($handle);
}
function processMessage($message) {
$message_id = $message['message_id'];
$chat_id = $message['chat']['id'];
if (isset($message)) {
$text = $message['text'];
if (strpos($text, "/start") === 0) {
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => HELLO_TEXT));
} else if (strpos($text, "/stop") === 0) {
} else {
apiRequest("sendMessage", array('chat_id' => $chat_id, "text" => DONE_TEXT));
apiRequest("forwardMessage", array('chat_id' => MY_ID, 'from_chat_id' => $chat_id, 'message_id' => $message_id));
}
}
}
if (php_sapi_name() == 'cli') {
apiRequest('setWebhook', array('url' => isset($argv[1]) && $argv[1] == 'delete' ? '' : WEBHOOK_URL));
exit;
}
$content = file_get_contents("php://input");
$update = json_decode($content, true);
if (!$update) {
exit;
}
if (isset($update["message"])) {
processMessage($update["message"]);
}
?>
<div class="row photos">
<?php
$apage = $_GET['page'];
if(isset($apage)){
$aoffset = $apage-1;
$aoffset = 16*$aoffset;
}
$fpt = file_get_contents('https://api.vk.com/method/photos.get?owner_id=-183487496&album_id=265483073&count=200&offset='.$aoffset.'&rev=1&access_token=a74&v=5.50');
$jjs = json_decode($fpt);
$jrnd = $jjs->response->count;
$apage = ceil($jrnd/16);
$x=-1;
while ($x<15)
{
$x++;
$pid = $jjs->response->items[$x]->photo_604;
echo '<div class="col-sm-6 col-md-4 col-lg-3 item"><a data-lightbox="photos" href="';
echo $pid;
echo '"><img class="img-fluid" src="';
echo $pid;
echo '"></a></div>';
}
?>
<ul class="pagination">
<?php
$z=0;
while ($z < $apage){
$z++;
echo '<li class="page-item"><a class="page-link"';
$bpage = 1;
if(isset($_GET['page'])){
$bpage = $_GET['page'];
}
if ($z != $bpage){
echo 'href="index.php?page=';
echo $z;
echo '"';
}
echo '>';
echo $z;
echo '</a></li>';
}
?>
</ul>
</div>
</div>
</div>