Hi! Could we please enable some services and cookies to improve your experience and our website?

PHPize Online / SQLize Online  /  SQLtest Online

A A A
Login    Share code      Blog   FAQ

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

Copy Format Clear

Stuck with a problem? Got Error? Ask AI support!

Copy Clear
Copy Format Clear
<?php // ******************************************************* // تنظیمات اصلی سیستم // ******************************************************* $botToken = '7113268834:AAGkuOvuCDodLGy_WoOO54IccRA249Q-YJY'; $adminChatId = 'YOUR_ADMIN_ID'; // آیدی عددی خود را جایگزین کنید $channelId = '@+MOtBqBmtdrM2NzZk'; // لینک کانال شما $dataFile = 'signals_data.json'; // فایل ذخیره داده‌ها $timezone = 'Asia/Tehran'; $userAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'; // تنظیم منطقه زمانی date_default_timezone_set($timezone); // ******************************************************* // تنظیمات پیشفرض سیستم // ******************************************************* // وبسایت‌های پیشفرض برای دریافت سیگنال $defaultWebsites = [ [ 'url' => 'https://www.coindesk.com/markets', 'channel_type' => 'crypto', 'asset_selector' => '.heading', 'entry_selector' => '.price-large', 'target_selector' => '.target-price', 'stop_loss_selector' => '.stop-loss', 'expiration_selector' => '.expiration' ], [ 'url' => 'https://www.tradingview.com/crypto-signals/', 'channel_type' => 'crypto', 'asset_selector' => '.tv-card-symbol', 'entry_selector' => '.tv-card-entry', 'target_selector' => '.tv-card-target', 'stop_loss_selector' => '.tv-card-stoploss', 'expiration_selector' => '.tv-card-expiration' ] ]; // ******************************************************* // توابع اصلی سیستم // ******************************************************* // تابع ارسال پیام به تلگرام function sendTelegram($botToken, $chatId, $text) { $url = "https://api.telegram.org/bot{$botToken}/sendMessage?" . http_build_query([ 'chat_id' => $chatId, 'text' => $text, 'parse_mode' => 'HTML' ]); return file_get_contents($url); } // تابع ذخیره و بازیابی داده‌ها function manageData($action = 'load', $newData = null) { global $dataFile, $defaultWebsites; if ($action === 'save') { file_put_contents($dataFile, json_encode($newData, JSON_PRETTY_PRINT)); return true; } if (!file_exists($dataFile)) { $initialData = [ 'websites' => $defaultWebsites, 'signals' => [], 'logs' => [] ]; file_put_contents($dataFile, json_encode($initialData, JSON_PRETTY_PRINT)); return $initialData; } return json_decode(file_get_contents($dataFile), true); } // تابع دریافت محتوای وبسایت function fetchWebsite($url) { global $userAgent; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_TIMEOUT, 30); $content = curl_exec($ch); curl_close($ch); return $content; } // تابع تولید سیگنال تستی function generateTestSignal() { $cryptoList = ['Bitcoin', 'Ethereum', 'Cardano', 'Solana', 'Dogecoin', 'Polkadot']; $asset = $cryptoList[array_rand($cryptoList)]; $entry = rand(30000, 60000); return [ 'signal_id' => 'SIG-' . time(), 'channel_type' => 'crypto', 'asset_name' => $asset, 'entry_price' => $entry, 'target_price' => $entry * 1.15, 'stop_loss' => $entry * 0.93, 'expiration_days' => rand(3, 7) ]; } // تابع قالب‌بندی پیام سیگنال function formatSignalMessage($signal) { return "🚀 سیگنال جدید ارز دیجیتال!\n\n" . "📛 دارایی: {$signal['asset_name']}\n" . "💰 قیمت ورود: " . number_format($signal['entry_price'], 2) . " USD\n" . "🎯 قیمت هدف: " . number_format($signal['target_price'], 2) . " USD\n" . "⛔ استاپ لاس: " . number_format($signal['stop_loss'], 2) . " USD\n" . "📅 اعتبار: {$signal['expiration_days']} روز\n" . "🆔 کد سیگنال: {$signal['signal_id']}"; } // ******************************************************* // اجرای اصلی سیستم // ******************************************************* // ارسال پیام راه‌اندازی به کانال $startMessage = "🤖 ربات سیگنال ارز دیجیتال فعال شد!\n" . "🕒 زمان: " . date('Y-m-d H:i:s') . "\n" . "✅ سیستم آماده دریافت سیگنال‌هاست"; sendTelegram($botToken, $channelId, $startMessage); // بارگیری داده‌های ذخیره شده $data = manageData(); // پردازش وبسایت‌ها و تولید سیگنال‌ها foreach ($data['websites'] as $website) { try { // دریافت محتوای وبسایت (در نسخه واقعی فعال شود) // $html = fetchWebsite($website['url']); // تولید سیگنال تستی (در نسخه واقعی باید با پارس کردن HTML جایگزین شود) $signal = generateTestSignal(); // ذخیره سیگنال $data['signals'][] = [ 'id' => $signal['signal_id'], 'data' => $signal, 'timestamp' => time() ]; // ارسال سیگنال به کانال $message = formatSignalMessage($signal); sendTelegram($botToken, $channelId, $message); // تاخیر بین سیگنال‌ها sleep(2); } catch (Exception $e) { // ذخیره خطا $data['logs'][] = [ 'error' => $e->getMessage(), 'website' => $website['url'], 'timestamp' => time() ]; } } // ذخیره داده‌های به‌روز شده manageData('save', $data); // گزارش نهایی $reportMessage = "✅ پردازش سیگنال‌ها با موفقیت انجام شد\n" . "🕒 زمان پایان: " . date('Y-m-d H:i:s') . "\n" . "📊 تعداد سیگنال‌های ارسال شده: " . count($data['signals']) . "\n" . "⚠️ تعداد خطاها: " . count($data['logs']); echo $reportMessage; sendTelegram($botToken, $adminChatId, $reportMessage); ?>
Copy Clear