!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 

uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 

uid=33(www-data) gid=33(www-data) groups=33(www-data) 

Safe-mode: OFF (not secure)

/var/www/html/queuepro/vendor/monolog/monolog/src/Monolog/Handler/   drwxrwxr-x
Free 12.97 GB of 57.97 GB (22.38%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     TelegramBotHandler.php (5.54 KB)      -rwxrwxr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php declare(strict_types=1);

/*
 * This file is part of the Monolog package.
 *
 * (c) Jordi Boggiano <j.boggiano@seld.be>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Monolog\Handler;

use 
RuntimeException;
use 
Monolog\Logger;

/**
 * Handler send logs to Telegram using Telegram Bot API.
 *
 * How to use:
 *  1) Create telegram bot with https://telegram.me/BotFather
 *  2) Create a telegram channel where logs will be recorded.
 *  3) Add created bot from step 1 to the created channel from step 2.
 *
 * Use telegram bot API key from step 1 and channel name with '@' prefix from step 2 to create instance of TelegramBotHandler
 *
 * @link https://core.telegram.org/bots/api
 *
 * @author Mazur Alexandr <alexandrmazur96@gmail.com>
 *
 * @phpstan-import-type Record from \Monolog\Logger
 */
class TelegramBotHandler extends AbstractProcessingHandler
{
    private const 
BOT_API 'https://api.telegram.org/bot';

    
/**
     * The available values of parseMode according to the Telegram api documentation
     */
    
private const AVAILABLE_PARSE_MODES = [
        
'HTML',
        
'MarkdownV2',
        
'Markdown'// legacy mode without underline and strikethrough, use MarkdownV2 instead
    
];

    
/**
     * Telegram bot access token provided by BotFather.
     * Create telegram bot with https://telegram.me/BotFather and use access token from it.
     * @var string
     */
    
private $apiKey;

    
/**
     * Telegram channel name.
     * Since to start with '@' symbol as prefix.
     * @var string
     */
    
private $channel;

    
/**
     * The kind of formatting that is used for the message.
     * See available options at https://core.telegram.org/bots/api#formatting-options
     * or in AVAILABLE_PARSE_MODES
     * @var ?string
     */
    
private $parseMode;

    
/**
     * Disables link previews for links in the message.
     * @var ?bool
     */
    
private $disableWebPagePreview;

    
/**
     * Sends the message silently. Users will receive a notification with no sound.
     * @var ?bool
     */
    
private $disableNotification;

    
/**
     * @param string $apiKey  Telegram bot access token provided by BotFather
     * @param string $channel Telegram channel name
     */
    
public function __construct(
        
string $apiKey,
        
string $channel,
        
$level Logger::DEBUG,
        
bool $bubble true,
        
string $parseMode null,
        
bool $disableWebPagePreview null,
        
bool $disableNotification null
    
) {
        if (!
extension_loaded('curl')) {
            throw new 
MissingExtensionException('The curl extension is needed to use the TelegramBotHandler');
        }

        
parent::__construct($level$bubble);

        
$this->apiKey $apiKey;
        
$this->channel $channel;
        
$this->setParseMode($parseMode);
        
$this->disableWebPagePreview($disableWebPagePreview);
        
$this->disableNotification($disableNotification);
    }

    public function 
setParseMode(string $parseMode null): self
    
{
        if (
$parseMode !== null && !in_array($parseModeself::AVAILABLE_PARSE_MODES)) {
            throw new 
\InvalidArgumentException('Unknown parseMode, use one of these: ' implode(', 'self::AVAILABLE_PARSE_MODES) . '.');
        }

        
$this->parseMode $parseMode;

        return 
$this;
    }

    public function 
disableWebPagePreview(bool $disableWebPagePreview null): self
    
{
        
$this->disableWebPagePreview $disableWebPagePreview;

        return 
$this;
    }

    public function 
disableNotification(bool $disableNotification null): self
    
{
        
$this->disableNotification $disableNotification;

        return 
$this;
    }

    
/**
     * {@inheritDoc}
     */
    
public function handleBatch(array $records): void
    
{
        
/** @var Record[] $messages */
        
$messages = [];

        foreach (
$records as $record) {
            if (!
$this->isHandling($record)) {
                continue;
            }

            if (
$this->processors) {
                
/** @var Record $record */
                
$record $this->processRecord($record);
            }

            
$messages[] = $record;
        }

        if (!empty(
$messages)) {
            
$this->send((string) $this->getFormatter()->formatBatch($messages));
        }
    }

    
/**
     * @inheritDoc
     */
    
protected function write(array $record): void
    
{
        
$this->send($record['formatted']);
    }

    
/**
     * Send request to @link https://api.telegram.org/bot on SendMessage action.
     * @param string $message
     */
    
protected function send(string $message): void
    
{
        
$ch curl_init();
        
$url self::BOT_API $this->apiKey '/SendMessage';
        
curl_setopt($chCURLOPT_URL$url);
        
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
        
curl_setopt($chCURLOPT_SSL_VERIFYPEERtrue);
        
curl_setopt($chCURLOPT_POSTFIELDShttp_build_query([
            
'text' => $message,
            
'chat_id' => $this->channel,
            
'parse_mode' => $this->parseMode,
            
'disable_web_page_preview' => $this->disableWebPagePreview,
            
'disable_notification' => $this->disableNotification,
        ]));

        
$result Curl\Util::execute($ch);
        if (!
is_string($result)) {
            throw new 
RuntimeException('Telegram API error. Description: No response');
        }
        
$result json_decode($resulttrue);

        if (
$result['ok'] === false) {
            throw new 
RuntimeException('Telegram API error. Description: ' $result['description']);
        }
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0051 ]--