update SQL
This commit is contained in:
parent
15a90639e1
commit
8d8347ca29
2 changed files with 73 additions and 2 deletions
|
|
@ -73,7 +73,7 @@ $now = $date->format('Y-m-d H:i:s');
|
||||||
$conn = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME", $DB_USER, $DB_PASS);
|
$conn = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME", $DB_USER, $DB_PASS);
|
||||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
|
||||||
$stmt = $conn->prepare("REPLACE INTO `tracker` (info_hash, ip, port, update_time) VALUES (:info_hash, :ip, :port, :update_time)");
|
$stmt = $conn->prepare("REPLACE INTO `peers` (info_hash, ip, port, update_time) VALUES (:info_hash, :ip, :port, :update_time)");
|
||||||
$stmt->bindValue(":info_hash", $hash, PDO::PARAM_STR);
|
$stmt->bindValue(":info_hash", $hash, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(":ip", is_loopback($ip) ? $externalIp : $ip, PDO::PARAM_STR);
|
$stmt->bindValue(":ip", is_loopback($ip) ? $externalIp : $ip, PDO::PARAM_STR);
|
||||||
$stmt->bindValue(":port", $port, PDO::PARAM_INT);
|
$stmt->bindValue(":port", $port, PDO::PARAM_INT);
|
||||||
|
|
@ -82,7 +82,7 @@ $stmt->execute();
|
||||||
|
|
||||||
$peers = '';
|
$peers = '';
|
||||||
|
|
||||||
$stmt = $conn->prepare("SELECT ip, port FROM `tracker` WHERE info_hash = :info_hash");
|
$stmt = $conn->prepare("SELECT ip, port FROM `peers` WHERE info_hash = :info_hash");
|
||||||
$stmt->bindValue(":info_hash", $hash, PDO::PARAM_STR);
|
$stmt->bindValue(":info_hash", $hash, PDO::PARAM_STR);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->bindColumn(1, $peerIp);
|
$stmt->bindColumn(1, $peerIp);
|
||||||
|
|
|
||||||
71
torrent.sql
Normal file
71
torrent.sql
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
-- phpMyAdmin SQL Dump
|
||||||
|
-- version 5.1.3
|
||||||
|
-- https://www.phpmyadmin.net/
|
||||||
|
--
|
||||||
|
-- Host: localhost
|
||||||
|
-- Generation Time: Mar 18, 2022 at 01:06 PM
|
||||||
|
-- Server version: 10.7.3-MariaDB
|
||||||
|
-- PHP Version: 7.4.28
|
||||||
|
|
||||||
|
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||||
|
START TRANSACTION;
|
||||||
|
SET time_zone = "+00:00";
|
||||||
|
|
||||||
|
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||||
|
/*!40101 SET NAMES utf8mb4 */;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Database: `torrent`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `peers`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `peers` (
|
||||||
|
`info_hash` char(40) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||||
|
`ip` varchar(40) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||||
|
`port` smallint(5) UNSIGNED NOT NULL,
|
||||||
|
`update_time` timestamp NOT NULL DEFAULT current_timestamp()
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Table structure for table `trackers`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE `trackers` (
|
||||||
|
`proto` char(5) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'http',
|
||||||
|
`host` varchar(64) COLLATE utf8mb4_unicode_ci NOT NULL,
|
||||||
|
`port` smallint(5) UNSIGNED NOT NULL DEFAULT 80,
|
||||||
|
`uri` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`passkey` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
|
||||||
|
`proxy` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for dumped tables
|
||||||
|
--
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `peers`
|
||||||
|
--
|
||||||
|
ALTER TABLE `peers`
|
||||||
|
ADD PRIMARY KEY (`info_hash`,`ip`,`port`);
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Indexes for table `trackers`
|
||||||
|
--
|
||||||
|
ALTER TABLE `trackers`
|
||||||
|
ADD PRIMARY KEY (`proto`,`host`,`port`);
|
||||||
|
COMMIT;
|
||||||
|
|
||||||
|
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||||
|
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||||
|
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||||
Loading…
Add table
Reference in a new issue