def push_function():
print("PUSH")
self.pushButton1.clicked.connect(push_function())
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php [QSA,L]
<?php
$redirect = $_SERVER['REQUEST_URI'];
switch ($redirect) {
case '/' :
case '' :
require __DIR__ . '/pages/home.php';
break;
case '/contact' :
require __DIR__ . '/pages/contact.php';
break;
default:
require __DIR__ . '/pages/404.php';
break;
}
?>
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Импорт тут нужен
import pymysql
# Подключение 1
def mysql_connection(*, ca_file=None, db="mysql", host="127.0.0.1", password, port, timeout=DEFAULT_MYSQL_TIMEOUT, user):
ssl = None
if ca_file:
ssl = {"ca": ca_file}
connection = pymysql.connect(
charset="utf8mb4",
connect_timeout=timeout,
cursorclass=pymysql.cursors.DictCursor,
db=db,
host=host,
password=password,
read_timeout=timeout,
port=port,
ssl=ssl,
user=user,
write_timeout=timeout,
)
try:
yield connection
finally:
connection.close()
# Подключение 2
def update_table_data(stats_dict, columns, year, table):
"""Update lahmandb with expanded stats."""
exp_p_columns = ['ROE', 'BAbip', 'OPS', 'SLG', 'OBP', 'WHIP',
'ERAplus', 'FIP', 'PA', 'SOperW', 'GIDP']
mydb = pymysql.connect(host, username, password, lahmandb)
cursor = mydb.cursor()
for key in stats_dict.keys():
stints = unpack_stints(key, stats_dict)
for stint in stints:
update_string = "UPDATE {} SET ".format(table)
for column in exp_p_columns:
stat = stint.get(column, 'NULL') # zero K's -> '' for K/BB
if not stat:
stat = 'NULL'
update_string += column + '=' + str(stat) + ', '
update_string = update_string[:-2] # strip off trailing comma
update_string += " WHERE playerID = '{}' AND yearID = {}".format(key, year)
update_string += " AND stint = {}".format(stint['stint'])
# print update_string
cursor.execute(update_string)
mydb.commit()
cursor.close()
# return update_strin
#Источник https://www.programcreek.com/python/example/53260/pymysql.connect
connect = pymysql.connect('lockhost', 'login, 'password', 'db',cursorclass=pymysql.cursors.DictCursor)
class commands:
def notesAll(self):
try:
with connect:
cursor = connect.cursor()
cursor.execute("""SELECT * FROM Notes""")
result = cursor.fetchall()
array_id = []
print(result)
for all_chats in result:
array_id.append(all_chats)
for i in range(len(array_id)):
day = datetime.now().day
month = datetime.now().month
year = datetime.now().year
year = f'{year}'
hour = datetime.now().hour
minute = datetime.now().minute
date = datetime.strptime(f'{day}.{month}.{year[0:2]} {hour}:{minute}', "%d.%m.%y %H:%M")
print(array_id[i]['dateTo'])
write_date = array_id[i]['dateTo'].split(' ')[0].split('.')[0] + '.' \
+ array_id[i]['dateTo'].split(' ')[0].split('.')[1] + '.' + \
array_id[i]['dateTo'].split(' ')[0].split('.')[2][0:2] + ' ' \
+ array_id[i]['dateTo'].split(' ')[1]
date1 = datetime.strptime(write_date, "%d.%m.%y %H:%M")
nu = ''
if date > date1:
nu = '⚠️ Врмя прошло!'
if array_id[i]['dateChange'] == 0:
change = ''
else:
change = f" Изменили -- {array_id[i]['dateChange']}\n"
msga = ' Информация о заметках!\n' \
f" ID -- {array_id[i]['id']}\n" \
f" Дата -- {array_id[i]['dateIn']} - {array_id[i]['dateTo']}\n" \
f'{change}' \
f" Создал заметку -- [id{array_id[i]['userId']}|{send.user_get(self, array_id[i]['userId'])}]\n" \
f" Текст -- {array_id[i]['text']}\n\n{nu}"
send.messages(self, msga, self.user_id)
if array_id == []:
msga = 'Нет заметок =('
send.messages(self, msga, self.user_id)
except Exception as error:
logging.exception(error)
class Bot:
def __init__(self, vk, group, longpoll):
self.vk = vk
self.group = group
self.longpoll = longpoll
thread1 = Thread(target=self.times, args=())
thread1.start()
def Running(self):
try:
while True:
for event in self.longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
self.event = event
self.chat_id = event.object.peer_id
self.user_id = event.object.from_id
if self.user_id in creator_id:
self.Commands()
except Exception as error:
logging.exception(error)
def Commands(self):
try:
body = self.event.object.text
body = self.delout(body)
body = body
if body[0:len('заметки') + 0:].lower() == 'заметки':
commands.notesAll(self)
except Exception as error:
logging.exception(error)
run = Bot(vk, group, longpoll)
thread1 = Thread(target=run.Running, args=())
thread1.start()
Сколько дней до соревнования или сколько монет нужно накопить?
Уровень наград состроит из 1000? Т.е. на тысячный день посещений человек получит 1000монет?
Можно задачу по проще и конкретнее?