09 SSL Mod

Started by Mindless, March 30, 2013, 07:49:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DragonCoder

#15
Quote from: autotron on December 10, 2013, 12:26:42 PM
Been a long time since I even looked at 08 source, but believe 08 did not use config.php
I think baseurl is defined in bittorrent.php

ok easy to add

ok make a config.php 
Add to include/config.php
With in the config add all functions from bittorrent then remove functions you just put in the config from bittorrent all you have to do is add to bittorrent is

require_once("config.php");

add to any pages you want it to show on like so on below a config.php

<?php

function local_user(){
          return 
$_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"];
}
add to what you want to add here line by line

             
if ($_SERVER["HTTP_HOST"] == "")                        // Root Based Installs Comment Out if in Sub-Dir
                 
$_SERVER["HTTP_HOST"] = $_SERVER["SERVER_NAME"];    // Comment out for Sub-Dir Installs
                 
$BASEURL "http://" $_SERVER["HTTP_HOST"];       // Comment out for Sub-Dir Installs
                 
$DEFAULTBASEURL "http://domainhere";


}
?>

denede

#14
.

mycrazy

#13
I think it was, right ?
$BASEURL = "http://" . $HTTP_SERVER_VARS["HTTP_HOST"];

to change this ?

$BASEURL = 'http'.(isset($_SERVER['HTTPS']) && (bool)$_SERVER['HTTPS'] == true ? 's':'').'://'. $_SERVER['HTTP_HOST'];

autotron

Been a long time since I even looked at 08 source, but believe 08 did not use config.php
I think baseurl is defined in bittorrent.php

mycrazy

Hi,
my config.php is empty, who will post the code below ?

Quoteconfig.php change the $TBDEV['baseurl'] to look like
Quote $TBDEV['baseurl'] = 'http'.(isset($_SERVER['HTTPS']) && (bool)$_SERVER['HTTPS'] == true ? 's':'').'://'. $_SERVER['HTTP_HOST'];

Mindless

Will its set up to drop into 09 which uses a different $GLOBAL string

TBdev 06-08 used $DEFAULTBASEURL =
Tbdev 09 used $TBDEV['baseurl'] =

So would be easier editing this mod and changing the global defines to the same format as yours, then swap any instance of $HTMLOUT with echo or print within any html, easy enough to do.

mycrazy

Hi,

how to install this mod to old TBDEV 06 or 08 ?

denede

yes i know that. but it's better to ask others than to do stupid things :)

Mindless

You will see it how i see it after years and months of this, that's how you learn, the instructions are based usually on default code, never factoring in additional mods, but if you look close enough you will see the differences =]

denede

yes, i suppose you are right... again :)

Mindless

#5
All your adding is after download.php?torrent=$id

Code (php) Select
download.php?torrent=$id

Will become

Code (php) Select
download.php?torrent=$id".($CURUSER['ssluse'] > 1 ? '&amp;ssl=1' : '')."

That is simple basic editing denede, the fact you say codes different from post is a complete cop out, use the head.

denede

know where the file is, but the line is different.

Mindless

mods/free_details.php.

denede

#2
thx for this
this would work for freeleech mod also ?
i'm looking in the freeleech file for the download link to modify but can't find it because in details i don't have a download link anymore, it's from the free files.

Mindless

Credit to putyn

config.php change the $TBDEV['baseurl'] to look like
Code (php) Select

$TBDEV['baseurl'] = 'http'.(isset($_SERVER['HTTPS']) && (bool)$_SERVER['HTTPS'] == true ? 's':'').'://'. $_SERVER['HTTP_HOST'];

also change the $TBDEV['announce'] array to look like
Code (php) Select

$TBDEV['announce_urls'] = array();

$TBDEV['announce_urls'][] = "http://localhost/announce.php";

$TBDEV['announce_urls'][] = "https://localhost/announce.php";
of course change localhost with your domain :P
now login.php add this code where you want to show the checkboxes
Code (php) Select

<tr>
          <td class='rowhead'>Use ssl</td>

          <td>

            <label for='ssl'>Browse the site using a secure connection just this session <input type='checkbox' name='use_ssl' checked='checked' value='1' id='ssl'/></label><br/>
            <label for='ssl2'>Browse the site using a secure connection permanently<input type='checkbox' name='perm_ssl' value='1' id='ssl2'/></label>

          </td>

      </tr>


now takelogin.php add under the logincookie function
Code (php) Select

if(isset($_POST['use_ssl']) && $_POST['use_ssl'] == 1 && !isset($_SERVER['HTTPS']))
      $TBDEV['baseurl'] = str_replace('http','https',$TBDEV['baseurl']);

if(isset($_POST['perm_ssl']) && $_POST['perm_ssl'] == 1)
      mysql_query('UPDATE users SET ssluse = 2 WHERE id = '.$row['id']) or sqlerr(__FILE__,__LINE__);


now go to my.php and add
Code (php) Select

$HTMLOUT .= "<fieldset><legend><strong>SSL for</strong></legend>
       <label><select name='ssluse'>
                <option value='1' ".($CURUSER['ssluse'] == 1 ? 'selected=\'selected\'' : '').">Nothing</option>
                <option value='2' ".($CURUSER['ssluse'] == 2 ? 'selected=\'selected\'' : '').">Only for site browsing (recommended)</option>
                <option value='3' ".($CURUSER['ssluse'] == 3 ? 'selected=\'selected\'' : '').">For site browsing and downloading (recommended)</option>
        </select>
    </label><br/><small>SSL (Secure Socket Layer) is a network layer security protocol which is reponsible for ensuring security of data</small></fieldset>";
where you want to display the select box

now add this inside takeprofedit.php
Code (php) Select

if(isset($_POST['ssluse']) && ($ssluse = (int)$_POST['ssluse']) && ($ssluse != $CURUSER['ssluse']))
      $updateset[] = "ssluse = ".$ssluse;


and open details.php and change this
Code (php) Select

$HTMLOUT .= "<tr><td class='rowhead' width='1%'>{$lang['details_download']}</td><td width='99%' align='left'><a class='index' href='download.php?torrent=$id'>" . htmlspecialchars($row["filename"]) . "</a></td></tr>";
//to this
$HTMLOUT .= "<tr><td class='rowhead' width='1%'>{$lang['details_download']}</td><td width='99%' align='left'><a class='index' href='download.php?torrent=$id".($CURUSER['ssluse'] > 1 ? '&amp;ssl=1' : '')."'>" . htmlspecialchars($row["filename"]) . "</a></td></tr>";


now in download.php add
Code (php) Select

$ssluse = isset($_GET['ssl']) && $_GET['ssl'] == 1 ? 1 : 0;
after $id
and change this line
Code (php) Select

$dict['value']['announce']['value'] = "{$TBDEV['announce_urls'][0]}?passkey={$CURUSER['passkey']}";
//like this
$dict['value']['announce']['value'] = "{$TBDEV['announce_urls'][$ssluse]}?passkey={$CURUSER['passkey']}";


now open bittorrent.php and add inside userlogin function after the select * from users query this
Code (php) Select

if($row['ssluse'] > 1 && !isset($_SERVER['HTTPS']) && !defined('NO_FORCE_SSL')) {
       $TBDEV['baseurl'] = str_replace('http','https',$TBDEV['baseurl']); 
         header('Location: '.$TBDEV['baseurl'].$_SERVER['REQUEST_URI']);
exit();
    }
dont add it exactly under should be under $row = mysql_fetch_assoc($res); :D

and the sql
Code (sql) Select

ALTER TABLE users ADD ssluse int(1) NOT NULL DEFAULT 1;


in announce you dont have to change anything but the announce was not tested :)
i didn't add any language cause im too lazy maybe someone else could add it :P
post any suggestions/bugs :)