Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Securing Your backup-database.php
You don't have permission for this action!
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Support

Unknown User
2011-11-19 02:33:12
By default backup-database.php sits in the root of your TorrentTrader Installation... This can be directly accessed and if people create a automatic bot with say a for loop and curl u could find your server full of backups which wasnt created by you or even worse because of the amount of system calls your server could die, Torrentialstorm said he used HTTP Authentication for his so i will show you how to do that here...

<?php

//

//  TorrentTrader v2.x

//  $LastChangedDate: 2011-11-18 04:28:50 +0000 (Fri, 18 Nov 2011) $

//  $LastChangedBy: dj-howarth1 $

//

//  http://www.torrenttrader.org

//

//



# For Security Purposes.



if ( $_SERVER['PHP_AUTH_USER'] != 'Username' && $_SERVER['PHP_AUTH_PASS'] != 'Password' )

{

 header('WWW-Authenticate: Basic realm="TT2-SVN"');

 header('HTTP/1.1 401 Unauthorized');

 die;

}



# Secured Code Here...

?>
If you experiment with the above code to any file it should show up like the screenshot if they press cancel nothing will appear, you can test this by below



# Secured Code Here...



Adding




echo "You are logged In.";



The default user & pass are Username and Password these could be changed to anything you desire and also the realm could be changed to anything it doesnt have to stay as TT2-SVN i put that there as im thinking of probably adding this to the svn, after you have tested this and if your happy then u can copy the contents of backup-database.php to below # Secured Code Here... and this will mean only Authenticated Users can create backups....

If you require any assistance feel free to reply.

HTTPAuth.PNG
HTTPAuth.PNG
Unknown User
2012-01-31 16:33:39
is it ok this tutorial?
Unknown User
2012-02-01 16:26:00
The tutorial looks ok but I would suggest that you remove backup-database.php and do all backups manually from your server control panel or phpmyadmin etc. Just my personal opinion but I feel much safer not having it in my root. Also if possible setup automatic daily backups to an external server or your home computer. A local backup isnt much use when the hdd of the server crashes. You can use the servers control panel if available, they usually provide some form of automatic backup (WHM/cpanel, DirectAdmin etc) or you can use something like Cobian backup [url="http://www.educ.umu.se/~cobian/cobianbackup.htm"]http://www.educ.umu....obianbackup.htm[/url] and configure it to pull a fresh backup daily.
Unknown User
2012-10-11 19:17:46
Hi

TT 2.08Final members modod's,basic donation,

site url:http://www.divxhunt.mine.su/

Apache version     2.2.21

PHP version     5.3.6

MySQL version     5.1.65-cll

Architecture     x86_64

OS: Red Hat 6.3 (Linux 2.6.18-238.12.1.el5.028stab091.1)

user: test

pass:123456

I end up with this !!??

Quote:
$backupdir = getcwd() . '/backups'; //Ensure this folder exists and is chmod 777 require_once("backend/mysql.php"); $today = getdate(); $day = $today["mday"]; if ($day < 10) { $day = "0$day"; } $month = $today["mon"]; if ($month < 10) { $month = "0$month"; } $year = $today["year"]; $hour = $today["hours"]; $min = $today["minutes"]; $sec = "00"; // Execute mysqldump command. // It will produce a file named $db-$year$month$day-$hour$min.sql.gz // under $backupdir system(sprintf( //'mysqldump --opt -h %s -u %s -p%s %s > %s/%s/%s-%s-%s-%s.sql', 'mysqldump --opt -h %s -u %s -p%s %s | gzip > %s/%s-%s-%s-%s.sql.gz', $mysql_host, $mysql_user, $mysql_pass, $mysql_db, $backupdir, $mysql_db, $day, $month, $year )); ?>
Unknown User
2012-10-19 09:28:08
Still need help!

Please
2012-11-25 19:14:24
worked fine. 2.08
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
Unknown User
2012-11-29 15:03:20
Got it! works fine...
Unknown User
2014-05-08 17:24:39
awesome.
2014-05-08 22:11:34
#1 big thanks Guest_XIII_  :D

<?php
//  TorrentTrader v2.x
//  $LastChangedDate: 2011-11-18 04:28:50 +0000 (Fri, 18 Nov 2011) $
//  $LastChangedBy: dj-howarth1 $
//
//  http://www.torrenttrader.org
//
if ( $_SERVER['PHP_AUTH_USER'] != 'test-name' && $_SERVER['PHP_AUTH_PASS'] != 'test-pass' )
{
      header('WWW-Authenticate: Basic realm="TT2-SVN"');
      header('HTTP/1.1 401 Unauthorized');
      die;
}

  require_once("backend/functions.php");[/php]

Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728