Skip to content

Commit

Permalink
Версия для DLE 13
Browse files Browse the repository at this point in the history
  • Loading branch information
Gokujo committed May 24, 2018
1 parent 0d14060 commit ac8554c
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 73 deletions.
10 changes: 5 additions & 5 deletions engine/ajax/maharder/telegram/cronadd.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
define( 'ROOT_DIR', dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ) );
define( 'ENGINE_DIR', ROOT_DIR . '/engine' );

include ENGINE_DIR . "/data/telegram.php";
include ENGINE_DIR . '/data/config.php';
include (DLEPlugins::Check(ENGINE_DIR . "/data/telegram.php"));
include (DLEPlugins::Check(ENGINE_DIR . '/data/config.php'));
date_default_timezone_set ( $config['date_adjust'] );

if( $config['http_home_url'] == "" ) {
Expand All @@ -29,11 +29,11 @@

}

require_once ENGINE_DIR . '/classes/mysql.php';
require_once ENGINE_DIR . '/data/dbconfig.php';
require_once (DLEPlugins::Check(ENGINE_DIR . '/classes/mysql.php'));
require_once (DLEPlugins::Check(ENGINE_DIR . '/data/dbconfig.php'));

if($telebot['onof'] && $telebot['cron']) {
require_once (ENGINE_DIR . "/inc/maharder/telegram/functions.php");
require_once (DLEPlugins::Check(ENGINE_DIR . "/inc/maharder/telegram/functions.php"));

if($telebot['cron_news'] > 0) $limit = "LIMIT " . $telebot['cron_news'];
else $limit = "";
Expand Down
4 changes: 2 additions & 2 deletions engine/inc/maharder/telegram/addnews.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
$id = intval($row);
if(!$id) return;

@include (ENGINE_DIR . '/data/'.$codename.'.php');
require_once (ENGINE_DIR . '/inc/maharder/'.$codename.'/functions.php');
@include (DLEPlugins::Check(ENGINE_DIR . '/data/'.$codename.'.php'));
require_once (DLEPlugins::Check(ENGINE_DIR . '/inc/maharder/'.$codename.'/functions.php'));

if($telebot['onof']) {

Expand Down
4 changes: 2 additions & 2 deletions engine/inc/maharder/telegram/editnews.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

$TIME = time();

@include (ENGINE_DIR . '/data/'.$codename.'.php');
require_once (ENGINE_DIR . '/inc/maharder/'.$codename.'/functions.php');
@include (DLEPlugins::Check(ENGINE_DIR . '/data/'.$codename.'.php'));
require_once (DLEPlugins::Check(ENGINE_DIR . '/inc/maharder/'.$codename.'/functions.php'));

if($telebot['onof']) {

Expand Down
5 changes: 4 additions & 1 deletion engine/inc/maharder/telegram/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@
'E-Mail' => "info@maxim-harder.de",
],
];
$version = "1.2";
$version = "1.2.1";
$descr = "Позволяет уведомлять пользователей в телеграме о новых добавлениях на сайте";
$changes = [
'1.2.1' => [
'Версия для DLE 13 и выше'
],
'1.2' => [
'Мелкие правки',
'Добавлена возможность использовать прокси (актуально для сайтов размещённых в РФ)',
Expand Down
18 changes: 9 additions & 9 deletions engine/inc/telegram.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

$codename = "telegram";

@include (ENGINE_DIR . '/data/'.$codename.'.php');
require_once (ENGINE_DIR . '/inc/maharder/assets/functions.php');
require_once (ENGINE_DIR . '/inc/maharder/'.$codename.'/version.php');
require_once (ENGINE_DIR . '/inc/maharder/'.$codename.'/functions.php');
@include (DLEPlugins::Check(ENGINE_DIR . '/data/'.$codename.'.php'));
require_once (DLEPlugins::Check(ENGINE_DIR . '/inc/maharder/assets/functions.php'));
require_once (DLEPlugins::Check(ENGINE_DIR . '/inc/maharder/'.$codename.'/version.php'));
require_once (DLEPlugins::Check(ENGINE_DIR . '/inc/maharder/'.$codename.'/functions.php'));

impFiles('css', $cssfiles);

Expand All @@ -26,23 +26,23 @@
switch ($_GET['do']) {

case 'save':
include (ENGINE_DIR . '/inc/maharder/'.$codename.'/save.php');
include (DLEPlugins::Check(ENGINE_DIR . '/inc/maharder/'.$codename.'/save.php'));
break;

case 'crontab':
include (ENGINE_DIR . '/inc/maharder/'.$codename.'/cron.php');
include (DLEPlugins::Check(ENGINE_DIR . '/inc/maharder/'.$codename.'/cron.php'));
break;

case 'chat_id':
include (ENGINE_DIR . '/inc/maharder/'.$codename.'/getChat.php');
include (DLEPlugins::Check(ENGINE_DIR . '/inc/maharder/'.$codename.'/getChat.php'));
break;

case 'sendMessage':
include (ENGINE_DIR . '/inc/maharder/'.$codename.'/sendMessage.php');
include (DLEPlugins::Check(ENGINE_DIR . '/inc/maharder/'.$codename.'/sendMessage.php'));
break;

default:
include (ENGINE_DIR . '/inc/maharder/'.$codename.'/default.php');
include (DLEPlugins::Check(ENGINE_DIR . '/inc/maharder/'.$codename.'/default.php'));
break;
}

Expand Down
56 changes: 6 additions & 50 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,55 +11,17 @@
define('ENGINE_DIR', ROOT_DIR.'/engine');
define('INC_DIR', ENGINE_DIR.'/inc');

require_once ENGINE_DIR.'/classes/mysql.php';
require_once INC_DIR.'/include/functions.inc.php';
include ENGINE_DIR.'/data/dbconfig.php';
include ENGINE_DIR.'/data/config.php';
require_once (ENGINE_DIR . '/inc/maharder/assets/functions.php');
require_once (ENGINE_DIR . '/inc/maharder/'.$codename.'/version.php');

if($config['version_id'] >= 13) die('Версия DLE равна или больше 13. Данная версия предназначена для версий 12.1 и ниже.');
if($config['version_id'] < 13) die('Версия DLE ниже 13. Данная версия предназначена для версий 13 и выше.');

$check_db = new db;
$check_db->connect(DBUSER, DBPASS, DBNAME, DBHOST, false);
if( version_compare($check_db->mysql_version, '5.6.4', '<') ) {
$storage_engine = "MyISAM";
} else $storage_engine = "InnoDB";
unset($check_db);

switch ($_GET['action']) {
case 'install':
try {
$tableSchema = array();
$tableSchema[] = "INSERT INTO " . PREFIX . "_admin_sections (name, title, descr, icon, allow_groups) VALUES ('{$codename}', '{$name} v{$version}', '{$descr}', '{$codename}.png', '1')";
$tableSchema[] = "CREATE TABLE IF NOT EXISTS " . PREFIX . "_telegram_cron ( cron_id int auto_increment primary key, news_id int not null, time timestamp null, type varchar(255) not null ) comment 'Отправка сообщений по крону';";
foreach ($tableSchema as $table) {
$db->query($table);
}
$html = "Успешно установлено";
} catch (Exception $e) {
$fail = $e->getMessage();
$html = "Произошла ошибка: {$fail}";
}
break;

case 'update':
try {
$tableSchema = array();
$tableSchema[] = "DELETE FROM " . PREFIX . "_admin_sections WHERE name = '{$codename}'";
$tableSchema[] = "INSERT INTO " . PREFIX . "_admin_sections (name, title, descr, icon, allow_groups) VALUES ('{$codename}', '{$name} v{$version}', '{$descr}', '{$codename}.png', '1')";
$tableSchema[] = "CREATE TABLE IF NOT EXISTS " . PREFIX . "_telegram_cron ( cron_id int auto_increment primary key, news_id int not null, time timestamp null, type varchar(255) not null ) comment 'Отправка сообщений по крону';";
foreach ($tableSchema as $table) {
$db->query($table);
}
$html = "Успешно обновлено";
} catch (Exception $e) {
$fail = $e->getMessage();
$html = "Произошла ошибка: {$fail}";
} break;

default:
$html = <<<HTML
$html = <<<HTML
<!DOCTYPE html>
<html lang="ru">
Expand Down Expand Up @@ -111,13 +73,11 @@
</div>
</h2>
<ol>
<li>Для установки достаточно закинуть в корень сайта все файлы и запустить <a href="{$_SERVER['PHP_SELF']}?action=install" target="_blank">этот скрипт <i class="fas fa-external-link-alt"></i></a> (раз вы это читаете, значит вы молодец).</li>
<li>В настройках модуля укажите токен бота и ID чата, иначе работать не будет.</li>
<li>Открываем <b>engine/inc/addnews.php</b> и ищем <pre class="prettyprint linenums">clear_cache( array('news_', 'tagscloud_', 'archives_', 'calendar_', 'topnews_', 'rss', 'stats') );</pre> и ставим выше <pre class="prettyprint linenums">include_once (ENGINE_DIR . "/inc/maharder/telegram/addnews.php");</pre></li>
<li>Открываем <b>engine/inc/editnews.php</b> и ищем <pre class="prettyprint linenums">clear_cache( array('news_', 'full_'.\$item_db[0], 'comm_'.\$item_db[0], 'tagscloud_', 'archives_', 'calendar_', 'rss', 'stats') );</pre> и ставим выше <pre class="prettyprint linenums">include_once (ENGINE_DIR . "/inc/maharder/telegram/editnews.php");</pre></li>
<li>Открываем <b>/cron.php</b> и ищем <pre class="prettyprint linenums">\$allow_cron = 0;</pre> и меняем значение на <pre class="prettyprint linenums">\$allow_cron = 1;</pre></li>
<li>Для установки достаточно закинуть в корень сайта все файлы</li>
<li>Установите <b>install_telegramposting.xml</b> в админпанеле <a href="{$config['http_home_url']}{$config['admin_path']}?mod=plugins" target="_blank">через систему плагинов <i class="fas fa-external-link-alt"></i></a>.</li>
<li>Открываем <b>/cron.php</b> и ищем <pre class="prettyprint linenums">\$allow_cron = 0;</pre> и меняем значение на <pre class="prettyprint linenums">\$allow_cron = 1;</pre></li>
<li>Ищем в <b>/cron.php</b> <pre class="prettyprint linenums">} elseif(\$cronmode == "antivirus") {</pre> и ставим выше <pre class="prettyprint linenums">} elseif(\$cronmode == "telegram") {
include(ENGINE_DIR . "/ajax/maharder/telegram/cronadd.php");
include_once (DLEPlugins::Check(ENGINE_DIR . "/ajax/maharder/telegram/cronadd.php"));
die ("done");
</pre></li>
<li>Удаляем install.php с корня сайта</li>
Expand Down Expand Up @@ -222,8 +182,4 @@
</html>
HTML;

break;

}

echo $html;
30 changes: 30 additions & 0 deletions install_telegramposting.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<dleplugin>
<name>Telegram Posting</name>
<description>Модуль будет отправлять сообщения в выбранный чат при помощи бота. Гибкие настройки позволят модулю отправлять лишь то, что вы хотите.</description>
<icon>engine/skins/images/telegram.png</icon>
<version>1.2.1</version>
<dleversion>13.0</dleversion>
<versioncompare>greater</versioncompare>
<mysqlinstall><![CDATA[INSERT INTO {prefix}_admin_sections (name, title, descr, icon, allow_groups) VALUES ('telegram', 'Telegram Posting v1.2.1', 'Публикация сообщений при появлении и / или обновлений новостей', 'telegram.png', '1');
CREATE TABLE IF NOT EXISTS {prefix}_telegram_cron ( cron_id int auto_increment primary key, news_id int not null, time timestamp null, type varchar(255) not null ) comment 'Отправка сообщений по крону';]]></mysqlinstall>
<mysqlupgrade><![CDATA[DELETE FROM {prefix}_admin_sections WHERE name = 'telegram';
INSERT INTO {prefix}_admin_sections (name, title, descr, icon, allow_groups) VALUES ('telegram', 'Telegram Posting v1.2.1', 'Публикация сообщений при появлении и / или обновлений новостей', 'telegram.png', '1');
CREATE TABLE IF NOT EXISTS {prefix}_telegram_cron ( cron_id int auto_increment primary key, news_id int not null, time timestamp null, type varchar(255) not null ) comment 'Отправка сообщений по крону';]]></mysqlupgrade>
<mysqlenable><![CDATA[INSERT INTO {prefix}_admin_sections (name, title, descr, icon, allow_groups) VALUES ('telegram', 'Telegram Posting v1.2.1', 'Публикация сообщений при появлении и / или обновлений новостей', 'telegram.png', '1');]]></mysqlenable>
<mysqldisable><![CDATA[DELETE FROM {prefix}_admin_sections WHERE name = 'telegram';]]></mysqldisable>
<mysqldelete><![CDATA[DELETE FROM {prefix}_admin_sections WHERE name = 'telegram';
DROP TABLE {prefix}_telegram_cron;]]></mysqldelete>
<file name="engine/inc/addnews.php">
<operation action="before">
<searchcode><![CDATA[clear_cache( array('news_', 'tagscloud_', 'archives_', 'calendar_', 'topnews_', 'rss', 'stats') );]]></searchcode>
<replacecode><![CDATA[include_once (DLEPlugins::Check(ENGINE_DIR . "/inc/maharder/telegram/addnews.php"));]]></replacecode>
</operation>
</file>
<file name="engine/inc/editnews.php">
<operation action="before">
<searchcode><![CDATA[clear_cache( array('news_', 'full_'.$item_db[0], 'comm_'.$item_db[0], 'tagscloud_', 'archives_', 'calendar_', 'rss', 'stats') );]]></searchcode>
<replacecode><![CDATA[include_once (DLEPlugins::Check(ENGINE_DIR . "/inc/maharder/telegram/editnews.php"));]]></replacecode>
</operation>
</file>
</dleplugin>
5 changes: 1 addition & 4 deletions Прочти меня.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
Установка
Установка / Обновление
1. Загрузить все файлы на сервер с перезаписью
2. Запустить файл www.ваш-сайт.ru/install.php
3. Следовать инструкциям

Обновление до 1.01
1. Заменить все файлы

0 comments on commit ac8554c

Please sign in to comment.