Skip to content

Commit

Permalink
PHP8 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
sergejey authored and Anisan committed Jun 24, 2023
1 parent 43ac7e8 commit d2a0951
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 72 deletions.
51 changes: 19 additions & 32 deletions modules/telegram/cmd_edit.inc.php
Expand Up @@ -32,34 +32,21 @@
if ($this->tab=='') {

// NAME
global $title;
$rec['TITLE']=$title;
global $description;
$rec['DESCRIPTION']=$description;
global $code;
$old_code=$rec['CODE'];
$rec['CODE'] = $code;
global $select_access;
$rec['ACCESS']=$select_access;

global $show_mode;
$rec['SHOW_MODE']=$show_mode;

global $linked_object_new;
$rec['LINKED_OBJECT']=$linked_object_new;
global $linked_property_new;
$rec['LINKED_PROPERTY']=$linked_property_new;
global $condition_new;
$rec['CONDITION']=$condition_new;
global $condition_value_new;
$rec['CONDITION_VALUE']=$condition_value_new;

global $priority;
$rec['PRIORITY']=$priority;
if ($rec['PRIORITY'] == "")
$rec['PRIORITY'] = 0;

global $users_id;
$rec['TITLE']=gr('title');
$rec['DESCRIPTION']=gr('description');

$old_code=isset($rec['CODE'])?$rec['CODE']:'';

$rec['CODE'] = gr('code');
$rec['ACCESS']=gr('select_access');
$rec['SHOW_MODE']=gr('show_mode');
$rec['LINKED_OBJECT']=gr('linked_object_new');
$rec['LINKED_PROPERTY']=gr('linked_property_new');
$rec['CONDITION']=gr('condition_new');
$rec['CONDITION_VALUE']=gr('condition_value_new');
$rec['PRIORITY']=gr('priority','int');

$users_id = gr('user_id');

if ($rec['TITLE'] == "")
{
Expand Down Expand Up @@ -92,7 +79,7 @@


if ($ok) {
if ($rec['ID']) {
if (isset($rec['ID'])) {
SQLUpdate($table_name, $rec); // update
updateAccess($rec['ID'],$users_id);
} else {
Expand All @@ -110,11 +97,11 @@
}

$res = SQLSelect("select ID,NAME,ADMIN, (SELECT count(*) FROM tlg_user_cmd where CMD_ID='$id' and tlg_user_cmd.USER_ID=tlg_user.ID) as ACCESS_USER from tlg_user");
if ($res[0]) {
if (isset($res[0])) {
$out['LIST_ACCESS'] = $res;
}
$res = SQLSelect("SELECT * from tlg_user_cmd where CMD_ID='$id'");
if ($res[0]) {
if (isset($res[0])) {
$qs = array();
foreach ($res as $row) {
$qs[] = $row['USER_ID'];
Expand All @@ -136,4 +123,4 @@ function updateAccess($cmd_id, $users_id) {
}
}

?>

20 changes: 7 additions & 13 deletions modules/telegram/event_edit.inc.php
Expand Up @@ -31,18 +31,12 @@
if ($this->tab=='') {

// NAME
global $title;
$rec['TITLE']=$title;
global $description;
$rec['DESCRIPTION']=$description;
global $code;
$old_code=$rec['CODE'];
$rec['CODE'] = $code;
global $enable;
$rec['ENABLE']=$enable;

global $type_event;
$rec['TYPE_EVENT']=$type_event;
$rec['TITLE']=gr('title');
$rec['DESCRIPTION']=gr('description');
$old_code=isset($rec['CODE'])?$rec['CODE']:'';
$rec['CODE'] = gr('code');
$rec['ENABLE']=gr('enable','int');
$rec['TYPE_EVENT']=gr('type_event');

if ($rec['TITLE'] == "")
{
Expand Down Expand Up @@ -73,7 +67,7 @@

//UPDATING RECORD
if ($ok) {
if ($rec['ID']) {
if (isset($rec['ID'])) {
SQLUpdate($table_name, $rec); // update
} else {
$new_rec=1;
Expand Down
45 changes: 44 additions & 1 deletion modules/telegram/telegram.class.php
Expand Up @@ -29,12 +29,14 @@ function __construct() {
$this->checkInstalled();

$this->getConfig();

$ip_ver = CURL_IPRESOLVE_WHATEVER;
if(strcmp("ipv4", $this->config['TLG_IPRESOLV']) == 0)
$ip_ver = CURL_IPRESOLVE_V4;
if(strcmp("ipv6", $this->config['TLG_IPRESOLV']) == 0)
$ip_ver = CURL_IPRESOLVE_V6;


if (!$this->config['TLG_USEPROXY'])
$this->telegramBot = new TelegramBot($this->config['TLG_TOKEN'],$ip_ver);
else
Expand All @@ -48,7 +50,46 @@ function __construct() {
$type_proxy = CURLPROXY_HTTPS;
$this->telegramBot = new TelegramBot($this->config['TLG_TOKEN'],$ip_ver,$this->config['TLG_PROXY_URL'],$this->config['TLG_PROXY_LOGIN'].':'.$this->config['TLG_PROXY_PASSWORD'], $type_proxy);
}

if (!isset($this->id)) $this->id=0;

}

function getConfig() {
parent::getConfig();

$setConfigKeys = array('TLG_IPRESOLV',
'TLG_USEPROXY',
'TLG_PROXY_TYPE',
'TLG_TOKEN',
'TLG_USEPROXY',
'TLG_PROXY_TYPE',
'TLG_PROXY_URL',
'TLG_PROXY_LOGIN',
'TLG_PROXY_PASSWORD',
'TLG_BOT_USERNAME',
'TLG_BOT_JOIN_GROUP',
'TLG_BOT_READ_GROUP',
'TLG_BOT_SUPPORT_INLINE',
'TLG_DEBUG',
'TLG_REG_USER',
'TLG_WEBHOOK',
'TLG_WEBHOOK_URL',
'TLG_WEBHOOK_CERT',
'TLG_TIMEOUT',
'TLG_STORAGE',
'TLG_COUNT_ROW',
'TLG_PLAYER',
'TLG_BOT_ID',
'TLG_BOT_NAME'
);

foreach($setConfigKeys as $k) {
if (!isset($this->config[$k])) $this->config[$k]='';
}
}


/**
* saveParams
*
Expand Down Expand Up @@ -171,7 +212,7 @@ function admin(&$out) {
}
else
{
if ((time() - gg('cycle_telegramRun')) < $this->config['TLG_TIMEOUT']*2 )
if ((time() - gg('cycle_telegramRun')) < (int)$this->config['TLG_TIMEOUT']*2 )
$out['CYCLERUN'] = 1;
else
$out['CYCLERUN'] = 0;
Expand Down Expand Up @@ -296,6 +337,8 @@ function admin(&$out) {
$out['TLG_COUNT_ROW'] = $this->config['TLG_COUNT_ROW'];
$out['TLG_PLAYER'] = $this->config['TLG_PLAYER'];
$out['TLG_TIMEOUT'] = $this->config['TLG_TIMEOUT'];
$out['TLG_PROXY_TYPE'] = $this->config['TLG_PROXY_TYPE'];

$out['BOT_ID'] = $this->config['TLG_BOT_ID'];
$out['BOT_NAME'] = $this->config['TLG_BOT_NAME'];
$out['BOT_USERNAME'] = $this->config['TLG_BOT_USERNAME'];
Expand Down
14 changes: 8 additions & 6 deletions modules/telegram/tlg_cmd.inc.php
@@ -1,20 +1,22 @@
<?php

global $session;

global $name;

$qry = "1";

$name = gr('name');
if ($name!='') {
$qry.=" AND TITLE LIKE '%".DBSafe($name)."%'";
$out['TITLE']=$name;
}


// FIELDS ORDER
global $sortby_cmd;
$sortby_cmd = gr('$sortby_cmd');
if (!$sortby_cmd) {
$sortby_cmd=$session->data['telegram_sort_cmd'];
$sortby_cmd=isset($session->data['telegram_sort_cmd'])?$session->data['telegram_sort_cmd']:'';
} else {
if ($session->data['telegram_sort_cmd']==$sortby_cmd) {
if (isset($session->data['telegram_sort_cmd']) && $session->data['telegram_sort_cmd']==$sortby_cmd) {
if (Is_Integer(strpos($sortby_cmd, ' DESC'))) {
$sortby_cmd=str_replace(' DESC', '', $sortby_cmd);
} else {
Expand All @@ -27,7 +29,7 @@
$out['SORTBY']=$sortby_cmd;

// SEARCH RESULTS
$res=SQLSelect("SELECT * FROM tlg_cmd ORDER BY ".$sortby_cmd);
$res=SQLSelect("SELECT * FROM tlg_cmd WHERE $qry ORDER BY ".$sortby_cmd);
if ($res[0]['ID']) {
paging($res, 20, $out); // search result paging
colorizeArray($res);
Expand Down
8 changes: 4 additions & 4 deletions modules/telegram/tlg_events.inc.php
Expand Up @@ -10,11 +10,11 @@


// FIELDS ORDER
global $sortby_event;
$sortby_event = gr('sortby_event');
if (!$sortby_event) {
$sortby_event=$session->data['telegram_sort_event'];
$sortby_event=isset($session->data['telegram_sort_event'])?$session->data['telegram_sort_event']:'';
} else {
if ($session->data['telegram_sort_event']==$sortby_event) {
if (isset($session->data['telegram_sort_event']) && $session->data['telegram_sort_event']==$sortby_event) {
if (Is_Integer(strpos($sortby_event, ' DESC'))) {
$sortby_event=str_replace(' DESC', '', $sortby_event);
} else {
Expand All @@ -28,7 +28,7 @@

// SEARCH RESULTS
$res=SQLSelect("SELECT * FROM tlg_event ORDER BY ".$sortby_event);
if ($res[0]['ID']) {
if (isset($res[0])) {
paging($res, 20, $out); // search result paging
colorizeArray($res);
$total=count($res);
Expand Down
30 changes: 14 additions & 16 deletions modules/telegram/tlg_users.inc.php
@@ -1,25 +1,27 @@
<?php

global $session;

global $uid;
if ($nid!='') {
$qry.=" AND USER_ID LIKE '%".DBSafe($nid)."%'";
$out['USER_ID']=$nid;

$qry = "1";

$uid = gr('uid');
if ($uid!='') {
$qry.=" AND USER_ID LIKE '%".DBSafe($uid)."%'";
$out['USER_ID']=$uid;
}

global $name;
$name = gr('name');
if ($name!='') {
$qry.=" AND NAME LIKE '%".DBSafe($name)."%'";
$out['NAME']=$name;
}

// FIELDS ORDER
global $sortby_user;
$sortby_user = gr('sortby_user');
if (!$sortby_user) {
$sortby_user=$session->data['tlg_user_sort'];
$sortby_user=isset($session->data['tlg_user_sort'])?$session->data['tlg_user_sort']:'';
} else {
if ($session->data['tlg_user_sort']==$sortby_user) {
if (isset($session->data['tlg_user_sort']) && $session->data['tlg_user_sort']==$sortby_user) {
if (Is_Integer(strpos($sortby_user, ' DESC'))) {
$sortby_user=str_replace(' DESC', '', $sortby_user);
} else {
Expand All @@ -32,14 +34,10 @@
$out['SORTBY']=$sortby_user;

// SEARCH RESULTS
$res=SQLSelect("SELECT * FROM tlg_user ORDER BY ".$sortby_user);
if ($res[0]['ID']) {
$res=SQLSelect("SELECT * FROM tlg_user WHERE $qry ORDER BY ".$sortby_user);
if (isset($res[0])) {
paging($res, 20, $out); // search result paging
colorizeArray($res);
$total=count($res);
for($i=0;$i<$total;$i++) {
// some action for every record if required
}
$out['RESULT']=$res;
}
?>

0 comments on commit d2a0951

Please sign in to comment.