|
22 | 22 | include 'func_cheque.php'; |
23 | 23 | include 'func_staking.php'; |
24 | 24 | include 'func_exchange.php'; |
25 | | -include 'func_exchange2.php'; |
| 25 | +include 'func_exchange2.php'; |
| 26 | +include 'func_subscribers.php'; |
26 | 27 |
|
27 | 28 | ################################# |
28 | 29 |
|
|
69 | 70 | ############### START ############### |
70 | 71 | if( preg_match("/\/start/i", $data['message']['text'] )){ |
71 | 72 |
|
72 | | -//register subscriber |
73 | | -$subscribersFile = 'subscribers.json'; |
74 | | -$first = isset($data['message']['from']['first_name']) ? $data['message']['from']['first_name'] : ''; |
75 | | -$last = isset($data['message']['from']['last_name']) ? $data['message']['from']['last_name'] : ''; |
76 | | -$usern = isset($data['message']['from']['username']) ? $data['message']['from']['username'] : ''; |
77 | | -$newrecord = [ |
78 | | - 'chat_id' => (int)$chat_id, |
79 | | - 'name' => trim(filter_var($first." ".$last, FILTER_SANITIZE_FULL_SPECIAL_CHARS)), |
80 | | - 'username' => trim(filter_var($usern, FILTER_SANITIZE_FULL_SPECIAL_CHARS)) |
81 | | -]; |
82 | | -$subscribers = []; |
83 | | -if(file_exists($subscribersFile)){ |
84 | | - $fileData = file_get_contents($subscribersFile); |
85 | | - $subscribers = json_decode($fileData, true); |
86 | | - if(!is_array($subscribers)) $subscribers = []; |
87 | | -} |
88 | | -$exists = false; |
89 | | -foreach($subscribers as $record){ |
90 | | - if($record['chat_id'] === $newrecord['chat_id']){ |
91 | | - $exists = true; |
92 | | - break; |
93 | | - } |
94 | | -} |
95 | | -if(!$exists){ |
96 | | - $subscribers[] = $newrecord; |
97 | | - file_put_contents($subscribersFile, json_encode($subscribers, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE), LOCK_EX); |
98 | | - @chmod($subscribersFile, 0600); |
99 | | -} |
100 | | -//register subscriber |
| 73 | +registerSubscriber($chat_id, $data); |
101 | 74 |
|
102 | 75 | $r = saveReferral($data); |
103 | 76 |
|
|
0 commit comments