<?php
require_once 'config.php';

$db->query("CREATE TABLE IF NOT EXISTS `users` (
    `userID` BIGINT(20) PRIMARY KEY,
    `Step` VARCHAR(50) DEFAULT 'none',
    `Flood` BIGINT(15) DEFAULT '0',
    `Ban` TINYINT(1) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");

$db->query("CREATE TABLE IF NOT EXISTS `files` (
    `rowID` BIGINT(20) AUTO_INCREMENT PRIMARY KEY,
    `userID` BIGINT(20) DEFAULT '0',
    `code` VARCHAR(20) DEFAULT '',
    `fileType` VARCHAR(30) DEFAULT '',
    `fileID` VARCHAR(5000) DEFAULT '',
    `fileCaption` VARCHAR(5000) DEFAULT '',
    `coverType` VARCHAR(30) DEFAULT '',
    `coverID` VARCHAR(300) DEFAULT '',
    `coverCaption` VARCHAR(5000) DEFAULT '',
    `passwordSet` VARCHAR(300) DEFAULT '',
    `likeCount` INT(10) DEFAULT '0',
    `disslikeCount` INT(10) DEFAULT '0',
    `downloadCount` INT(10) DEFAULT '0',
    `fileDTime` VARCHAR(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");

$db->query("CREATE TABLE IF NOT EXISTS `dFile` (
    `rowID` BIGINT(20) AUTO_INCREMENT PRIMARY KEY,
    `userID` BIGINT(20) DEFAULT '0',
    `msgID` BIGINT(20) DEFAULT '0',
    `delay` VARCHAR(30) DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");

$db->query("CREATE TABLE IF NOT EXISTS `downloads` (
    `rowID` BIGINT(20) AUTO_INCREMENT PRIMARY KEY,
    `userID` BIGINT(20) DEFAULT '0',
    `mainFile` BIGINT(20) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");

$db->query("CREATE TABLE IF NOT EXISTS `likes` (
    `rowID` BIGINT(20) AUTO_INCREMENT PRIMARY KEY,
    `userID` BIGINT(20) DEFAULT '0',
    `Type` TINYINT(1) DEFAULT '0',
    `mainFile` BIGINT(20) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");

$db->query("CREATE TABLE IF NOT EXISTS `channel_set` (
    `rowID` BIGINT(20) AUTO_INCREMENT PRIMARY KEY,
    `chatID` VARCHAR(20) NOT NULL,
    `chatTitle` VARCHAR(1000) NOT NULL,
    `chatLink` VARCHAR(120) NOT NULL,
    `chatType` TINYINT(1) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");

$db->query("CREATE TABLE IF NOT EXISTS `buttons` (
    `rowID` BIGINT(20) AUTO_INCREMENT PRIMARY KEY,
    `btnType` TINYINT(1) DEFAULT '0',
    `btnName` VARCHAR(300) DEFAULT '',
    `btn_fileType` VARCHAR(30) DEFAULT '',
    `btn_Message` VARCHAR(5000) DEFAULT '',
    `btn_fileID` VARCHAR(300) DEFAULT ''
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");

$db->query("CREATE TABLE IF NOT EXISTS `ads_set` (
    `rowID` INT(2) PRIMARY KEY,
    `adsPlace` TINYINT(1) DEFAULT '0',
    `adsType` VARCHAR(30) DEFAULT '',
    `adsMessage` VARCHAR(5000) DEFAULT '',
    `adsFile` VARCHAR(300) DEFAULT '',
    `adsfromChat` BIGINT(20) DEFAULT '0',
    `adsMessageId` BIGINT(20) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");

$db->query("CREATE TABLE IF NOT EXISTS `bot_texts` (
    `rowID` INT(2) PRIMARY KEY,
    `start` VARCHAR(2000) DEFAULT '',
    `caption` VARCHAR(2000) DEFAULT '',
    `password` VARCHAR(300) DEFAULT '',
    `joinChannel` VARCHAR(2000) DEFAULT '',
    `viewchannel` VARCHAR(2000) DEFAULT '',
    `antiFilter` VARCHAR(2000) DEFAULT '',
    `cover` VARCHAR(2000) DEFAULT '',
    `coverCaption` VARCHAR(2000) DEFAULT '',
    `delayTime` INT(3) DEFAULT '60',
    `viewTime` INT(2) DEFAULT '10'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");

$db->query("CREATE TABLE IF NOT EXISTS `panel` (
    `rowID` INT(2) PRIMARY KEY,
    `Power` TINYINT(1) DEFAULT '1',
    `antiFilter` TINYINT(1) DEFAULT '0',
    `viewChannel` TINYINT(1) DEFAULT '0',
    `downloadCount` TINYINT(1) DEFAULT '0',
    `likesOption` TINYINT(1) DEFAULT '0',
    `mainMenu` TINYINT(1) DEFAULT '0',
    `userUpload` TINYINT(1) DEFAULT '0',
    `groupDownload` TINYINT(1) DEFAULT '1',
    `resendButton` TINYINT(1) DEFAULT '1',
    `leftNotification` TINYINT(1) DEFAULT '0',
	`protectContent` TINYINT(1) DEFAULT '0',
    `btn_rowLength` TINYINT(1) DEFAULT '2'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");

$db->query("CREATE TABLE IF NOT EXISTS `admin_list` (
    `userID` BIGINT(20) PRIMARY KEY,
    `state` TINYINT(1) DEFAULT '1',
    `sendAll` TINYINT(1) DEFAULT '0',
    `upload` TINYINT(1) DEFAULT '1',
    `channels` TINYINT(1) DEFAULT '0',
    `setText` TINYINT(1) DEFAULT '0',
    `setBox` TINYINT(1) DEFAULT '0',
    `btnPart` TINYINT(1) DEFAULT '0',
    `userPart` TINYINT(1) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");
        
$db->query("CREATE TABLE IF NOT EXISTS `sendAll` (
    `rowID` INT(2) PRIMARY KEY,
    `Type` VARCHAR(30) DEFAULT '-',
    `Count` INT(10) DEFAULT '0',
	`OffSet` INT(10) DEFAULT '0',
    `sType` VARCHAR(30) DEFAULT '-',
    `TxCap` VARCHAR(5000) DEFAULT '-',
    `Media` VARCHAR(1000) DEFAULT '-',
    `FromID` BIGINT(20) DEFAULT '0',
    `MsgID` BIGINT(20) DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_persian_ci;");

if($db->query("SELECT `rowID` FROM `ads_set`")->num_rows< 1)
    $db->query("INSERT INTO `ads_set`(`rowID`) VALUES ('85');");

if($db->query("SELECT `rowID` FROM `bot_texts`")->num_rows< 1)
    $db->query("INSERT INTO `bot_texts`(`rowID`) VALUES ('85');");

if($db->query("SELECT `rowID` FROM `panel`")->num_rows< 1)
    $db->query("INSERT INTO `panel`(`rowID`) VALUES ('85');");
        
if($db->query("SELECT `rowID` FROM `sendAll`")->num_rows< 1)
    $db->query("INSERT INTO `sendAll`(`rowID`) VALUES ('85');");
