Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easier setup: auto-detect tracker address if no config file found. #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ipmagnet.ini.php
11 changes: 6 additions & 5 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ Requirements

Setup
Clone the repo into a folder that is available by the httpd.
Edit index.php
Change the tracker URL (line 2) to point to the public
Optionally, copy the sample config file (ipmagnet.ini.php-sample)
to ipmagnet.ini.php and change its settings. Options include:
Change the tracker URL to point to the public
location of the index.php file.

Optionally edit the database path (line 3) if you do not
want to have the database in the same folder for security
reasons.
Change the database path to point to the location of the
ipmagnet.db3 file if you want to have the database in a
different folder than index.php for security reasons.

If you'd like to set a timeout after which clients should recheck their
IP against the tracking link, set $enableInterval to true on line 4.
Expand Down
12 changes: 10 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?php
$TRACKER=urlencode("http://localhost:80/ipmagnet/");
$db = new PDO("sqlite:ipmagnet.db3");
$cnfgFile=dirname(__FILE__) . '/ipmagnet.ini.php';
if(file_exists($cnfgFile)){
$cnfg=parse_ini_file($cnfgFile);
}
$TRACKER = (empty($cnfg['tracker']))
? urlencode("http://{$_SERVER['HTTP_HOST']}".dirname($_SERVER['PHP_SELF']).'/')
: urlencode($cnfg['tracker']);
$db = (empty($cnfg['db_path']))
? new PDO("sqlite:ipmagnet.db3")
: new PDO("sqlite:$db_path");
$enableInterval=false;
$trackerInterval=300;

Expand Down
19 changes: 19 additions & 0 deletions ipmagnet.ini.php-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
; This is a sample configuration for the IPMagnet torrent IP testing tool.
; It sets the default tracker address that you may wish to use, or modify.
; Copy this file to `ipmagnet.ini.php`, then make changes there.
;
; This file uses "init file" formatting. To learn more about the syntax of this
; file, please refer to the PHP manual:
;
; http://php.net/parse_ini_file
;
;<?php
; exit('Direct access to this file is prohibited.');
;// EDIT BELOW THESE LINES.
;/*

tracker="http://localhost:80/ipmagnet/"
db_path="ipmagnet.db3"

;*/
;?>