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
Common Pool with FreeLeech (Pot commun)
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Mods Completed

2023-02-02 04:37:31
------------------------------------- ENGLISH ----------------------------------------

I have made a Common Pool MOD with a GLOBAL FreeLeech.

This MOD work with Seed Bonus Points. Make sure you have the SeedBonus MOD. Members participate in raising bonus points in a common pool. When the total points are reached, the freeleech is activated for all members for 48 hours.

The total number of points required can be edited in the "config.php" file as well as the duration of the FreeLeech.

-------------------------------------- FRENCH -----------------------------------------

J'ai fait un MOD Pot Commun avec un FreeLeech GLOBAL.

Ce MOD fonctionne avec les Points Bonus. Assurez-vous d'avoir le MOD SeedBonus. Les membres participent à faire monter les points bonus dans un pot commun. Lorsque le total de points est atteint, le freeleech est activé pour tous les membres durant 48 heures.

Le total de points nécessaires est éditable dans le fichiers "config.php" ainsi que la durée du FreeLeech.


IN "index.php"

FIND

//check
if (file_exists("check.php") && $CURUSER["class"] == 8){
show_error_msg("WARNING", "Check.php still exists, please delete or rename the file as it could pose a security risk<br /><br /><a href='check.php'>View Check.php</a> - Use to check your config!<br /><br />",0);
}


ADD BELOW

//Common Pot (By OXYDE - torrenttrader.uk)
if ($site_config['COMMONPOT']){
begin_frame(T_("COMMONPOT"));

$res_commonpot = SQL_Query_exec("SELECT SUM(points) AS total FROM commonpot");
$pot = mysqli_fetch_array($res_commonpot);
$percent = (($pot["total"] / $site_config["COMMONPOT_SIZE"]) * 100);

$res_commonpot_status = SQL_Query_exec("SELECT * FROM commonpot_status");
$pot_status = mysqli_fetch_array($res_commonpot_status);

$now = get_date_time();
$delay = $site_config["FREELEECH_TIME"];
$duration = date('Y-m-d H:i:s', strtotime(" + $delay hours"));
$stop_date = date("Y-m-d H:i:s", strtotime("+ $delay hours", strtotime($pot_status['start_date'])));

if ($pot_status["status"] == "stopped" && $pot["total"] == $site_config["COMMONPOT_SIZE"]) { $status_text = "<font color='#00FF00'>Le pot est plein et le FreeLeech commencera dans les prochaines minutes!</font>"; $participate = ""; }

elseif ($pot_status["status"] == "started" && $stop_date <= $now) { $status_text = "<font color='#00FF00'>Le FreeLeech est terminé et pot sera réinitialisé dans les prochaines minutes.</font>"; $participate = ""; }

elseif ($pot_status["status"] == "started") { $status_text = "Le pot est plein et le <font color='#ffcd03'><b>FreeLeech de ".$site_config["FREELEECH_TIME"]." heures</b></font> est <font color='#BFFF00'><b>ACTIVÉ</b></font> pour tous!<br>Il se terminera le  </b><font color='#FFA500'><b>" . date( "M d, Y H:i:s", utc_to_tz_time( $pot_status['stop_date'] ) ) . "</b>"; $participate = ""; } else { $status_text = "Un FreeLeech de 48 heures sera offert pour tous lorsque le pot commun sera rempli à 100%. Aide tes amis à tomber en FreeLeech et tu feras des heureux!"; $participate = "[ <a href='commonpot.php'>Je participe</a> ]"; }

if (empty($pot["total"])) { $pot_total = "0"; } else { $pot_total = $pot["total"]; }

?>
<table align='center'><tr><td style='padding: 0px; width: 500px; background-image: url(<?= $site_config["LOADBAR_IMG"] ?>loadbarbg.gif); background-repeat: repeat-x'>
<?php
if ($percent <= 70)
$pic = "loadbargreen.gif";
elseif ($percent <= 90)
$pic = "loadbaryellow.gif";
else
$pic = "loadbarred.gif";
$width = $percent * 5;
print("<img src='" . $site_config["LOADBAR_IMG"] . $pic . "' height='15' width='$width' alt='$percent%'><div style='position:relative;top:-15px;margin:auto;width:50%;color:#000;text-align:center;font-weight:bold;'>".$pot_total." / ".$site_config["COMMONPOT_SIZE"]." [".rtrim(rtrim((string)number_format($percent, 3, ".", ""),"0"),".")."%]</div><div style='float:right;'><p align='right' style='font-size:13px;color:#FFF;font-weight:bold;'>$participate</p><p align='right' style='font-size:13px;color:#FFF;font-weight:bold;'>[ <a href='commonpot-history.php'>Historique</a> ]</p></div>$status_text");

echo "</td></tr>";
echo "</table>";

end_frame();
}
//End Common Pot (By OXYDE - torrenttrader.uk)


IN "backend/functions/cleanup.php" or "backend/cleanup.php"

AT THE END OF FILE BEFORE

}

?>


ADD

// COMMON POT (By OXYDE - torrenttrader.uk)
$res_commonpot = SQL_Query_exec("SELECT SUM(points) AS total FROM commonpot");
$pot = mysqli_fetch_array($res_commonpot);
$res_commonpot_status = SQL_Query_exec("SELECT * FROM commonpot_status");
$pot_status = mysqli_fetch_array($res_commonpot_status);

$now = get_date_time();
$delay = $site_config["FREELEECH_TIME"];
$duration = date('Y-m-d H:i:s', strtotime(" + $delay hours"));
$stop_date = date("Y-m-d H:i:s", strtotime("+ $delay hours", strtotime($pot_status['start_date'])));

if ($pot_status["status"] == "stopped" && $now >= $pot_status["stop_date"] && $pot["total"] == $site_config["COMMONPOT_SIZE"]) {
SQL_Query_exec("UPDATE commonpot_status SET status='started', start_date='$now', stop_date='$duration'");
}elseif ($pot_status["status"] == "started" && $now >= $stop_date && $pot["total"] == $site_config["COMMONPOT_SIZE"] ) {
SQL_Query_exec("UPDATE commonpot_status SET status='stopped', start_date=NULL, stop_date=NULL");
SQL_Query_exec("TRUNCATE TABLE commonpot");
}
// END COMMON POT (By OXYDE - torrenttrader.uk)


IN "backend/functions/torrents.php" or "backend/torrents.php"

FIND

		$expandrows = array_map("trim", $expandrows);
}
// End


ADD AFTER

//Common Pot (By OXYDE - torrenttrader.uk)
$res_pot = SQL_Query_exec("SELECT status FROM commonpot_status");
$pot = mysqli_fetch_assoc($res_pot);
//End Common Pot (By OXYDE - torrenttrader.uk)


FIND

if ($row["freeleech"] == 1)


REPLACE BY

if ($row["freeleech"] == "1" || $pot["status"] == "started")


IN "torrents-details.php"

FIND

$tag5 = '';


ADD AFTER

//Common Pot (By OXYDE - torrenttrader.uk)
$res_pot = SQL_Query_exec("SELECT status FROM commonpot_status");
$pot = mysqli_fetch_assoc($res_pot);
//End Common Pot (By OXYDE - torrenttrader.uk)


FIND

if ($row["external"]!='yes' && $row["freeleech"]=='1'){


REPLACE BY

if ($row["external"]!='yes' && $row["freeleech"]=='1' || $row["external"]!='yes' && $pot["status"] == "started"){


IN "languages/english.php" or "languages/french.php"

AT THE END OF FILE BEFORE

?>


ADD

// Common Pot
$LANG["COMMONPOT"] = "POT COMMUN";


IN "backend/system/config.php" or "backend/config.php"

AT THE END OF FILE BEFORE

?>


ADD

// Common Pot
$site_config["LOADBAR_IMG"] = "images/loadbar/"; // Loadbar images location
$site_config["COMMONPOT"] = true; // Common Pot STATUS
$site_config["COMMONPOT_SIZE"] = "100000";   // Number of seed bonus points needed in common pot to start the GLOBAL FRELEECH FOR ALL.
$site_config["FREELEECH_TIME"] = "48"; // Duration of the GLOBAL FREELEECH when he started in hours (Default: 48).


AND FINALLY EXTRACT THE RAR ARCHIVE AT THE ROOT OF YOUR WEBSITE AND EXECUTE THE SQL FILE "commonpot.sql" TO YOUR DATABASE INCLUDED IN THE "SQL" FOLDER OF THE RAR.

NOTE:

------------------------------------- ENGLISH ----------------------------------------

I didn't have time to translate everything and integrate it into the english.php or french.php file because I don't need it on my site. But if someone is brave enough to do it, go!

-------------------------------------- FRENCH -----------------------------------------

Je n'ai pas eu le temps de traduire le tout et de l'intégrer dans le fichier english.php ou french.php car je j'en ai pas de besoin sur mon site. Mais si quelqu'un est assez brave pour le faire, go!

Common Pool.rar
Download
Last edited by OXYDE on 2023-02-02 04:56:05
2023-02-02 19:37:07
Merci pour cette belle fonction mais quand on click sur  [ Je participe ] ou sur  [ Historique ] on a une page blanche avec ce message d'erreur

Thanks for this nice function but when you click on [ I participate ] or on [ History ] you get a blank page with this error message






Cette page ne fonctionne pas
Impossible de traiter cette demande  à l'heure actuelle.

HTTP ERROR 500


This page does not work
Unable to process this request at this time.

HTTP ERROR 500
2023-02-03 01:02:00
allo niki retire

require_once($_SERVER["DOCUMENT_ROOT"]."/backend/functions/functions.php"

et change pour

require_once("backend/functions.php");

Corriger les deux fichiers
Last edited by spiritblue on 2023-02-03 01:04:20
2023-02-03 16:03:33
Bonjour spiritblue et un tout grand merci pour ton aide car ça fonctionne bien maintenant  👍
2023-02-03 16:15:57
$_SERVER["DOCUMENT_ROOT"]

__DIR__ works too, cleaner
2023-02-03 17:41:30
Hello and thank you too
2023-02-03 18:20:08
je reviens car quand on ajoute les points dans la case de participer au pot commun et que l'on click sur le bouton  "participer!"  j'ai ce message d'erreur


et le code d'erreur dans staff cp erreur sql j'ai ce message d'erreur

Database Error in commonpot.php on line 39: Incorrect integer value: '' for column `forum_tg`.`commonpot`.`id` at row 1. Query was: INSERT INTO commonpot (id, userid, points, added) VALUES('', 1, 200, '2023-02-03 18:17:16').





I come back because when I add the points in the box to participate in the common pot and I click on the button "participate!" I have this error message


and the error code in staff cp sql error I get this error message

Database Error in commonpot.php on line 39: Incorrect integer value: '' for column `forum_tg`.`commonpot`.`id` at row 1. Query was: INSERT INTO commonpot (id, userid, points, added) VALUES('', 1, 200, '2023-02-03 18:17:16').
2023-02-03 20:39:43
cool. Thanks for sharing. I was tinkering, and for testing I wanted a quick way to reset it, so I added a button in the admincp to clear it and reset. You can fix up the language file as you see fit
///////////////// CLEAR COMMON POOL /////////////////////////////

if ($action == "clearpool") {

   stdhead(T_("CLEAR_COMMON_POOL"));
   error_reporting(E_ALL);
   
   begin_frame("".T_("CLEAR_COMMON_POOL")."");
   
   if ($do != "clearpoolforreal") {
       ?>
       <br /><br />
       <font size ='3'><center><?php echo T_("CLEAR_COMMON_POOL_MESSAGE"); ?></center></font>
       <br /><br />
       
       <form enctype="multipart/form-data" method="post" action="admincp.php">
       <input type="hidden" name="action" value="clearpool" />
       <input type="hidden" name="do" value="clearpoolforreal" />
       <table class="f-border" cellspacing="0" cellpadding="5" width="100%" align="center">
       <tr><td colspan="2" align="center"><input type="submit" value="<?php echo T_("CLEAR_COMMON_POOL");?>" /></td></tr>
       </table></form>
       <?php
   }
   
   if ($do == "clearpoolforreal") {
       SQL_Query_exec("UPDATE commonpot_status SET status='stopped', start_date=NULL, stop_date=NULL");
       SQL_Query_exec("TRUNCATE TABLE commonpot");
       write_log("Common Pool cleared by $CURUSER[username]");
       autolink ("admincp.php", "<b><font color='#ff0000'> Common Pool Cleared....</font></b>");
   }
   
   end_frame();
   navmenu();
   stdfoot();
}
   ///////////////END CLEAR COMMON POOL //////////////////////////////////////////////


my lang
$LANG["CLEAR_COMMON_POOL"] = "Clear Common Pool";
$LANG["CLEAR_COMMON_POOL_MESSAGE"] = "Are you sure you want to reset the pool?";
$LANG["COMMON_POOL_CLEARED_MESSAGE"] = "Common Pot cleared and reset";

the button in admincp (you have to get an image to use if you like)
  <td align="center"><a href="admincp.php?action=clearpool"><img src="images/admin/poolclear.png" border="0" width="118" height="80" alt="" /><br /><?php echo T_("CLEAR_COMMON_POOL"); ?><br /></a></td>

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)
Last edited by MicroMonkey on 2023-02-05 21:25:49
2023-02-03 21:01:03
is there a primary index on forum_tg? is forum_tg the same as "id"?
2023-02-03 21:28:54
one more thing, this code goes into the backend/functions.php file in case someone hasnt figured it out. I think the OP made a typo
find
		$expandrows = array_map("trim", $expandrows);
}

below put
	//Common Pot (By OXYDE - torrenttrader.uk)
$res_pot = SQL_Query_exec("SELECT status FROM commonpot_status");
$pot = mysqli_fetch_assoc($res_pot);
//End Common Pot (By OXYDE - torrenttrader.uk)

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)
Last edited by MicroMonkey on 2023-02-03 21:30:17
2023-02-04 03:48:18
Excuse me if a typo was made I have a different version of V3 with backend/functions/* and backend/system/* folders. All functions was seperated of each others. Not all in the same like de original TT.
2023-02-04 06:07:48
No worries. Thanks again for sharing. Very cool mod. I made some edits for myself on the index. I figure if you can give hours, you can also give days for freeleech. Still have to use hours as the config number, eg: 24 hours = 1 day, 72 hours = 3 days, etc. and it will not show the history button if nobody has participated (its set to .001 for 1 seed point) I was just having fun playing around.
index.php
//Common Pot (By OXYDE - torrenttrader.uk)
if ($site_config['COMMONPOT']){
  begin_frame(T_("COMMONPOT"));
 
  $res_commonpot = SQL_Query_exec("SELECT SUM(points) AS total FROM commonpot");
  $pot = mysqli_fetch_array($res_commonpot);
  $percent = (($pot["total"] / $site_config["COMMONPOT_SIZE"]) * 100);
 
  $res_commonpot_status = SQL_Query_exec("SELECT * FROM commonpot_status");
  $pot_status = mysqli_fetch_array($res_commonpot_status);
 
  $now = get_date_time();
  $delay = $site_config["FREELEECH_TIME"];
  if ($delay >= 24) {
      $delay = floor($delay / 24);
      $unit = "days";
  } else {
      $unit = "hours";
  }
  $duration = date("M j, Y g:i a", strtotime(" + $delay $unit"));
  $stop_date = date("M j, Y g:i a", strtotime("+ $delay $unit", strtotime($pot_status['start_date'])));
  if ($pot_status["status"] == "stopped" && $pot["total"] == $site_config["COMMONPOT_SIZE"]) { $status_text = "<font color='#00FF00'>The pot is full and freeLeech will start in the next few minutes!</font>"; $participate = ""; }
 
  elseif ($pot_status["status"] == "started" && $stop_date <= $now) { $status_text = "<font color='#00FF00'>FreeLeech is over and pot will be reset in the next few minutes.</font>"; $participate = ""; }
 
  elseif ($pot_status["status"] == "started") { $status_text = "The pot is full and freeleech is <font color='#BFFF00'><b>ACTIVE</b></font> for <font color='#ffcd03'><b> $delay $unit</b></font> for everyone!<br>It will end on  </b><font color='#FFA500'><b>" . date( "M j, Y g:i a", utc_to_tz_time( $pot_status['stop_date'] ) ) . "</b>"; $participate = ""; } else { $status_text = "$delay $unit of freeleech will be offered for everyone when the common pot is 100% full. Help increase the pot!"; $participate = "[ <a href='commonpot.php'>participate</a> ]"; }
 
  if (empty($pot["total"])) { $pot_total = "0"; } else { $pot_total = $pot["total"]; }
 
  ?>
  <table align='center'><tr><td style='padding: 0px; width: 500px; background-image: url(<?= $site_config["LOADBAR_IMG"] ?>loadbarbg.gif); background-repeat: repeat-x'>
  <?php
  if ($percent <= 50)
  $pic = "loadbarred.gif";
  elseif ($percent <= 70)
  $pic = "loadbaryellow.gif";
  else
  $pic = "loadbargreen.gif";
  $width = $percent * 5;

  if ($percent >= .001) {
     echo "<img src='" . $site_config["LOADBAR_IMG"] . $pic . "' height='15' width='$width' alt='$percent%'><div style='position:relative;top:-15px;margin:auto;width:50%;color:#000;text-align:center;font-weight:bold;'>" . $pot_total . " / " . $site_config["COMMONPOT_SIZE"] . " [" . rtrim(rtrim((string)number_format($percent, 3, ".", ""), "0"), ".") . "%]</div><div style='float:right;'><p align='right' style='font-size:13px;color:#FFF;font-weight:bold;'>" . $participate . "</p><p align='right' style='font-size:13px;color:#FFF;font-weight:bold;'>[ <a href='commonpot-history.php'>History</a> ]</p></div>" . $status_text;
 } else {
     echo "<img src='" . $site_config["LOADBAR_IMG"] . $pic . "' height='15' width='$width' alt='$percent%'><div style='position:relative;top:-15px;margin:auto;width:50%;color:#000;text-align:center;font-weight:bold;'>" . $pot_total . " / " . $site_config["COMMONPOT_SIZE"] . " [" . rtrim(rtrim((string)number_format($percent, 3, ".", ""), "0"), ".") . "%]</div><div style='float:right;'><p align='right' style='font-size:13px;color:#FFF;font-weight:bold;'>" . $participate . "</p></div>" . $status_text;
 }
  echo "</td></tr>";
  echo "</table>";
 
  end_frame();
  }
  //End Common Pot (By OXYDE - torrenttrader.uk)

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)
Last edited by MicroMonkey on 2023-02-04 09:46:16
2023-02-04 08:19:15
I come back because when I add the points in the box to participate in the common pot and I click on the button "participate!" I have this error message


Database Error. Please report this to an administrator.


and the error code in staff cp sql error I get this error message

Database Error in commonpot.php on line 39: Incorrect integer value: '' for column `forum_tg`.`commonpot`.`id` at row 1. Query was: INSERT INTO commonpot (id, userid, points, added) VALUES('', 1, 200, '2023-02-03 18:17:16').



below the value on the database



           
Last edited by niki on 2023-02-04 08:47:18
2023-02-04 09:39:43
what is this? Did you edit something? Those column names are not mentioned in this mod code anywhere. Check your edits
column `forum_tg`.`commonpot`.`id` 

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)
Last edited by MicroMonkey on 2023-02-04 09:44:06
2023-02-04 10:05:11
thanks for the help and I haven't changed anything and when I want to add the points then when I click on the button I participate I get this error message


Database Error. Please report this to an administrator.

and my seedbonus point is deducted from my account but it is not added to the kitty?
Last edited by niki on 2023-02-04 10:06:04
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