<?php
/*
dev: https://factweb.ir
channel telegram : @factwebir
*/
error_reporting(0);
include "config.php";
define('API_KEY',$API_KC); 
//-----------------------------------------------------------------------------------------------
$connect->query("CREATE TABLE IF NOT EXISTS `accounts` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `keyapi` text DEFAULT NULL,
  PRIMARY KEY (`id`)
)");

$connect->query("CREATE TABLE IF NOT EXISTS `admins` (
  `idadmin` varchar(20) NOT NULL,
  `nameadmin` varchar(100) DEFAULT NULL,
  PRIMARY KEY (`idadmin`)
)");

$connect->query("CREATE TABLE IF NOT EXISTS `ai_config` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `model_name` varchar(50) NOT NULL,
  `status` enum('on','off') DEFAULT 'on',
  `input_price` int(11) NOT NULL,
  `output_price` int(11) DEFAULT 0,
  `has_output` tinyint(1) DEFAULT 0,
  PRIMARY KEY (`id`)
)");

$connect->query("CREATE TABLE IF NOT EXISTS `channels` (
  `idoruser` varchar(100) NOT NULL,
  `link` varchar(200) NOT NULL,
  `type` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`idoruser`)
)");

$connect->query("CREATE TABLE IF NOT EXISTS `pays` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` varchar(30) NOT NULL,
  `amount` int(11) NOT NULL,
  `order_id` varchar(20) NOT NULL,
  `sub_id` varchar(200) NOT NULL,
  `status` enum('pending','completed') NOT NULL DEFAULT 'pending',
  `created_at` varchar(50) NOT NULL,
  `msgid` int(20) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `order_id` (`order_id`),
  KEY `user_id` (`user_id`)
)");

$connect->query("CREATE TABLE IF NOT EXISTS `peyment` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `merichentzarin` text DEFAULT NULL,
  `merichentzib` text DEFAULT NULL,
  `wallettron` text DEFAULT NULL,
  `typepay` varchar(20) DEFAULT NULL,
  `vaztron` varchar(5) DEFAULT NULL,
  `vazonlinepay` varchar(5) DEFAULT NULL,
  `walletton` text DEFAULT NULL,
  `vazton` varchar(10) DEFAULT NULL,
  PRIMARY KEY (`id`)
)");

$connect->query("CREATE TABLE IF NOT EXISTS `settings` (
  `botid` varchar(30) NOT NULL,
  `bot_mode` varchar(20) NOT NULL,
  `forall` varchar(20) NOT NULL,
  `sendall` varchar(20) NOT NULL,
  `tedad` varchar(20) NOT NULL,
  `text` text NOT NULL,
  `chat_id` varchar(20) NOT NULL,
  `sendedit` varchar(20) NOT NULL,
  `is_all` varchar(20) NOT NULL,
  `factwebir` varchar(20) NOT NULL,
  `msg_id` varchar(20) NOT NULL,
  `modebot` varchar(5) DEFAULT NULL,
  `alljoin` int(10) DEFAULT NULL,
  `pton` varchar(20) DEFAULT NULL,
  `ptron` varchar(20) DEFAULT NULL,
  `pdolar` varchar(20) DEFAULT NULL,
  `starttext` text DEFAULT NULL,
  `helptext` text DEFAULT NULL,
  `invgift` int(20) DEFAULT NULL,
  `startgift` int(20) DEFAULT NULL,
  `bannertext` text DEFAULT NULL,
  `bannerfile` text DEFAULT NULL,
  `balanceall` varchar(10) DEFAULT 'false',
  `amount` int(11) DEFAULT 0,
  PRIMARY KEY (`botid`)
)");

$connect->query("CREATE TABLE IF NOT EXISTS `transactions` (
  `codecomment` varchar(20) NOT NULL,
  `userid` varchar(20) DEFAULT NULL,
  `priceton` varchar(20) DEFAULT NULL,
  `timeexpire` varchar(100) DEFAULT NULL,
  `amount` varchar(20) DEFAULT NULL,
  PRIMARY KEY (`codecomment`)
)");

$connect->query("CREATE TABLE IF NOT EXISTS `user` (
  `id` bigint(64) NOT NULL,
  `step` text NOT NULL,
  `step2` text NOT NULL,
  `step3` text NOT NULL,
  `spam` varchar(20) NOT NULL,
  `name` varchar(150) DEFAULT NULL,
  `chat_history` text DEFAULT NULL,
  `balance` int(20) DEFAULT NULL,
  `request` int(20) DEFAULT NULL,
  `members` int(20) DEFAULT NULL,
  `invited` tinyint(4) DEFAULT 0,
  PRIMARY KEY (`id`)
)");

$connect->query("CREATE TABLE IF NOT EXISTS `wallet` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `user_id` varchar(150) DEFAULT NULL,
  `private_key` text DEFAULT NULL,
  `address_base58` text DEFAULT NULL,
  PRIMARY KEY (`id`)
)");
//-----------------------------------------------------------------------------------------------
if($settings['botid'] == null ){
    $connect->query("INSERT INTO `settings` (`botid`, `bot_mode`, `forall`, `sendall`, `tedad`, `text`, `chat_id`, `sendedit`, `is_all`, `factwebir`, `msg_id`, `modebot`, `alljoin`, `pton`, `ptron`, `pdolar`, `starttext`, `helptext`, `invgift`, `startgift`, `bannertext`, `bannerfile`, `balanceall`, `amount`) 
    VALUES ('$botid', 'on', 'false', 'false', '0', 'none', '0', 'none', 'no', 'no', 'none', 'sub', 0, '4.802', '0.24771', '83530', 'start', 'help', 200, 500, 'banner', NULL, 'false', 0)");

    $connect->query("INSERT INTO `peyment` (`id`, `merichentzarin`, `merichentzib`, `wallettron`, `typepay`, `vaztron`, `vazonlinepay`, `walletton`, `vazton`) 
    VALUES (1, 'merichent', 'merichent', 'wallet tron', 'ziball', 'on', 'on', 'wallet ton', 'on')");

    $connect->query("INSERT INTO `ai_config` (`id`, `model_name`, `status`, `input_price`, `output_price`, `has_output`) VALUES
    (1, 'ai_gemini2', 'on', 14, 56, 1),
    (2, 'ai_cohere', 'on', 47, 140, 1),
    (3, 'ai_meta', 'on', 20, 20, 1),
    (4, 'ai_gpt4o', 'on', 233, 931, 1),
    (5, 'ai_gemini15', 'on', 14, 56, 1),
    (6, 'ai_claude35', 'on', 74, 372, 1),
    (7, 'ai_gpt4omini', 'on', 14, 56, 1),
    (8, 'ai_gpt35turbo', 'on', 47, 140, 1),
    (9, 'ai_deepseek_chat', 'on', 25, 102, 1),
    (10, 'ai_text_embedding_large', 'on', 2, 2, 1),
    (11, 'ai_text_embedding_small', 'on', 2, 2, 1),
    (12, 'ai_dalle2', 'on', 1900, 0, 0),
    (13, 'ai_dalle3', 'on', 4100, 0, 0),
    (14, 'ai_gpt4o_vision', 'on', 232, 944, 1),
    (15, 'tools_tts', 'on', 2000, 0, 0),
    (16, 'tools_stt', 'on', 100, 0, 0),
    (17, 'tools_removebg', 'on', 100, 0, 0),
    (18, 'tools_inhanceface', 'on', 100, 0, 0),
    (19, 'tools_expandface', 'on', 110, 0, 0),
    (20, 'tools_effect', 'on', 2500, 0, 0)");
} 

echo "<b>جداول دیتابیس ربات با موفقیت ایجاد شدند</b>";