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
New Config Approach
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / M-BiTsy / M-BiTsy Support

2021-07-08 17:04:18
We mentioned the TT installer which i am looking at and some settings would have to be separate to make it easier.
The db name and site name etc so while playing with that i thought about all the other settings.

This is something that i probably wont post for v3 so here is the process in case any one finds it useful this will be added to pdo version this weekend

first include the new config file with the array inside
$config = include APPROOT.'/config/configgg.php';


here is the config array file
<?php
return array (
"DB_HOST", "localhost",
"DB_USER", "torrenttrader",
"DB_PASS", "password",
"DB_NAME", "pdo",
'DB_CHAR' => 'utf8mb4',
'URLROOT' => 'http://localhost/torrenttraderpdo',
'CAPTCHA_ON' => false,
'CAPTCHA_KEY' => 'googlecaptchakey',
'CAPTCHA_SECRET' => 'googlecaptchasecret',
'APPROOT' => dirname(dirname(__FILE__)),
'CACHE' => '../data/cache',
'LANG' => '../data/languages/',
'TORRENTDIR' => '../data/uploads',
'NFODIR' => '../data/uploads',
'BLOCKSDIR' => '../views/blocks',
'IMPORT' => '../data/import',
'LOGGER' => '../data/logs',
'BACUP' => '../data/backups',
'SITENAME' => 'TorrentTraderMVC',
'_SITEDESC' => 'A PHP support forum for Torrent Trader',
'SITEEMAIL' => 'something@email.com',
'VERSION' => 'PDO',
'TT_TIME' => time(),
'TT_DATE' => date("Y-m-d H:i:s"),
'CACHE_TYPE' => 'disk',
'MEMCACHE_HOST' => 'localhost',
'MEMCACHE_PORT' => 11211,
'SITENOTICEON' => true,
'SITENOTICE' => 'Welcome To TorrentTrader MVC/PDO',
'DEFAULTLANG' => 'english',
'DEFAULTTHEME' => 'darktheme',
'CHARSET' => 'utf-8',
'ANNOUNCELIST' => URLROOT . '/announce.php',
'MEMBERSONLY' => true,
'MEMBERSONLY_WAIT' => true,
'ALLOWEXTERNAL' => true,
'UPLOADERSONLY' => false,
'INVITEONLY' => false,
'ENABLEINVITES' => true,
'CONFIRMEMAIL' => false,
'ACONFIRM' => false,
'ANONYMOUSUPLOAD' => false,
'PASSKEYURL' => URLROOT . '/announce.php?passkey=%s',
'UPLOADSCRAPE' => true,
'FORUMS' => true,
'FORUMS_GUESTREAD' => false,
'OLD_CENSOR' => false,
'MAXUSERS' => 20000,
'MAXUSERSINVITE' => 50000,
'CURRENCYSYMBOL' => '£',
'BONUSPERTIME' => 0.1,
'ADDBONUS' => 3600,
'FORCETHANKS' => false,
'ALLOWLIKES' => true,
'BANNED_AGENTS' => '-AZ21, -BC, LIME',
'IMAGEMAXFILESIZE' => 524288,
'ALLOWEDIMAGETYPES' => array(
   "image/gif" => ".gif",
   "image/pjpeg" => ".jpg",
   "image/jpeg" => ".jpg",
   "image/jpg" => ".jpg",
   "image/png" => ".png",
),

'SITE_ONLINE' => true,
'OFFLINEMSG' => 'Site is down for a little while',
'WELCOMEPM_ON' => true,
'WELCOMEPM_MSG' => 'Thank you for registering at our tracker! Please remember to keep your ratio at 1.00 or greater',
'UPLOADRULES' => 'You should also include a .nfo file wherever possible<br />Try to make sure your torrents are well-seeded for at least 24 hours<br />Do not re-release material that is still active',
'ISURL' => array('login', 'logout', 'signup'),
'LEFTNAV' => true,
'RIGHTNAV' => true,
'MIDDLENAV' => true,
'SHOUTBOX' => true,
'NEWSON' => true,
'DONATEON' => true,
'DISCLAIMERON' => true,
'CLASS_WAIT' => 1,
'GIGSA' => 1,
'RATIOA' => 0.50,
'A_WAIT' => 24,
'GIGSB' => 3,
'RATIOB' => 0.65,
'B_WAIT' => 12,
'GIGSC' => 5,
'RATIOC' => 0.80,
'C_WAIT' => 6,
'GIGSD' => 7,
'RATIOD' => 0.95,
'D_WAIT' => 2,
'PEERLIMIT' => 10000,
'AUTOCLEANINTERVAL' => 600,
'LOGCLEAN' => 28 * 86400,
'ANNOUNCEINTERVAL' => 900,
'SIGNUPTIMEOUT' => 259200,
'MAXDEADTORRENTTIMEOUT' => 21600,
'RATIOWARNENABLE' => true,
'RATIOWARNMINRATIO' => 0.4,
'RATIOWARN_MINGIGS' => 4,
'RATIOWARN_DAYSTOWARN' => 14,
'TORRENTTABLE_COLUMNS' => 'category,name,dl,magnet,tube,imdb,uploader,comments,size,seeders,leechers,health,external,added',
'TORRENTTABLE_EXPAND' => '',
'mail_type' => 'php',
'mail_smtp_host' => 'localhost',
'mail_smtp_port' => 25,
'mail_smtp_ssl' => false,
'mail_smtp_auth' => false,
'mail_smtp_user' => '',
'mail_smtp_pass' => '',
'_USER' => 1,
'_POWERUSER' => 2,
'_VIP' => 3,
'_UPLOADER' => 4,
'_MODERATOR' => 5,
'_SUPERMODERATOR' => 6,
'_ADMINISTRATOR' => 7,
'FORUMONINDEX' => true,
'IPCHECK' => true,
'ACCOUNTMAX' => 1,
'IMDB1' => true,
'YOU_TUBE' => true,
'FREELEECHGBON' => true,
'FREELEECHGB' => 8589934592,
'REQUESTSON' => true,
'HIDEBBCODE' => true,
'HNR_ON' => false,
'HNR_DEADLINE' => 7 * 86400,
'HNR_SEEDTIME' => 172800,
'HNR_WARN' => 5,
'HNR_STOP_DL' => 5,
'HNR_BAN' => 50,
'HNR_DISABLED' => TRUE,
)
?>


Next i use a class with static method - just so i dont have to include global every where
<?php
class Config
{

   public static function TT()
   {
       global $config;
       return $config;
   }

}


all instances of $site_config need to be changed for example $site_config['siteurl'] becomes Config::TT()['siteurl']

now the array file is all set we can manage in admincp page - here is the simple way for example

<?php
// do some checks - for username ?
       if ($_SESSION["control_panel"] != "yes" || $_SESSION["username"] != "mjay") {
           Redirect::to(URLROOT . "/logout");
       }
// get form input all post input names need to match array key name
if ($_POST) {
       file_put_contents(
           APPROOT.'/config/configgg.php',
           "<?php\nreturn " . var_export($_POST, true) . "\n?>"
       );
}

// now the form this is just the version example - still need to finish this just repeat input form for each config setting
<?php
echo Config::TT()['VERSION'];
?>
<form method="post" action="' . URLROOT . '/adminconfig/submit">
<div class="row justify-content-md-center">
<div class="col-md-8">';
////////////////////////////////////
// example for config setting array
<center><label for="ttversion">TTversion:</label><br></center>
<input type="text"  class="form-control" id="ttversion" name="ttversion" value="<?php echo Config::TT()['VERSION'] ?>">
////////////////////////////////////
<br><br>
<center><input type="submit"  class="btn btn-sm ttbtn" value="Submit"></center>
</div>
</div>
</form>



Here is the start of the installer

the url/install/index.php
<?php
// get any files we need & the installer class
include 'installer.php';
include '../../app/config/config.php';
include '../../app/libraries/DB.php';

// use $_get to set step
$Step = $_GET['step'] ?? 0;

// call the installer
$Installer = new Installer();

// run everything through installer class
if ($Step == 1) {
   $Installer->step1();
} elseif ($Step == 2) {
   $Installer->step2();
} elseif ($Step == 3) {
   $Installer->step3();
} elseif ($Step == 4) {
   $Installer->step4();
} elseif ($Step == 5) {
   $Installer->step5();
} else {
   $Installer->index();
}


the installer class im thinking just forms and extension checks a bit like check.php but also a few methods to install sql

just stated working on this
<?php
class Installer
{

   public function index()
   {
     $html =  '<!DOCTYPE html>
<html>
<head>
<style>
.center {
 margin: auto;
 width: 60%;
 border: 3px solid #73AD21;
 padding: 10px;
}
</style>
</head>
<body>

<center><h2>Lets do some checks</h2><center>
<form method="post" action="index.php?step=1">
<div class="center">
 //   database details use session so set on all pages
 <input type="submit" value="Submit">
</div>
</form>
</body>
</html>';
echo $html;
   }

   public function step1()
   {
       $sql = file_get_contents('Full Database.sql');
       $qr = DB::exec($sql);
   }

}

Last edited by M-jay warn on 2021-07-24 23:38:19
2021-07-24 23:40:59
1st post updated just got the forms left to do for pdo version
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: 8
  • Members: 0
  • Guests online: 8
  • Comments: 3
  • Messages: 1,728