09 Poster Mod & Last 5/Top 5

Started by Mindless, July 21, 2012, 10:06:40 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

0day

#8
same for , '".$poster."'
Code (php) Select

implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, $CURUSER["id"], "no",



to
Code (php) Select

implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, '".$poster."', $CURUSER["id"], "no",


NOTE:'".$poster."' is wrong.The correct is $poster and I tested for tbdev09

denede

how can I edit this, so there will be displayed a different poster for each category ? i don't want that uploaders have to choose pictures.

Daniel

no worries mate im just  figuring it out why it would do it xD  and really a big thanks for the tbdev section :-)

Quote from: Mindless on July 21, 2012, 11:21:42 AM
Right back to basics - sql_query to mysql_query, If you would give me time to post all the mods first before firing in, i have a massive job on my hands here so patience is key young man =]

Mindless

#5
Right back to basics - sql_query to mysql_query, If you would give me time to post all the mods first before firing in, i have a massive job on my hands here so patience is key young man =]

Daniel

adding this

// 09 poster mod
    $query = "SELECT id, name, poster FROM torrents WHERE poster <> '' ORDER BY added DESC limit 15";
  //  $result = sql_query( $query );
    $num = mysql_num_rows( $result );
    // count rows
    $HTMLOUT .="<script type='text/javascript' src='{$TBDEV['baseurl']}/scripts/scroll.js'></script>";
    $HTMLOUT .= "<div style='text-align:center;width:80%;border:0px solid blue;padding:5px;'><div style='background:#00345B;height:25px;'><span style='font-weight:bold;font-size:12pt;'>{$lang['index_latest']}</span></div><br />
    <div style=\"overflow:hidden\">
    <div id=\"marqueecontainer\" onmouseover=\"copyspeed=pausespeed\" onmouseout=\"copyspeed=marqueespeed\">
    <span id=\"vmarquee\" style=\"position: absolute; width: 98%;\"><span style=\"white-space: nowrap;\">";
    $i = 20;
    while ( $row = mysql_fetch_assoc( $result ) ) {
        $id = (int) $row['id'];
        $name = htmlspecialchars( $row['name'] );
        $poster = htmlspecialchars( $row['poster'] );
        $name = str_replace( '_', ' ' , $name );
        $name = str_replace( '.', ' ' , $name );
        $name = substr( $name, 0, 50 );
        if ( $i == 0 )
        $HTMLOUT .= "</span></span><span id=\"vmarquee2\" style=\"position: absolute; width: 98%;\"></span></div></div><div style=\"overflow:hidden\">
        <div id=\"marqueecontainer\" onmouseover=\"copyspeed=pausespeed\" onmouseout=\"copyspeed=marqueespeed\"> <span id=\"vmarquee\" style=\"position: absolute; width: 98%;\"><span style=\"white-space: nowrap;\">
        <a href='{$TBDEV['baseurl']}/details.php?id=$id'><img src='" . htmlspecialchars( $poster ) . "' alt='$name' title='$name' width='100' height='120' border='0' /></a>";
        $i++;
    }
    $HTMLOUT .= "</span></span><span id=\"vmarquee2\" style=\"position: absolute; width: 98%;\"></span></div></div></div><br />\n";
    //== end 09 poster mod

gives me following error
Fatal error: Call to undefined function sql_query() in /var/www/index.php on line 152
removing above line  gives me below errors   :o below error must be because there is no torrents on site ?
Notice: Undefined variable: result in /var/www/index.php on line 153 Warning: mysql_num_rows() expects parameter 1 to be resource, null given in /var/www/index.php on line 153 Notice: Undefined variable: result in /var/www/index.php on line 161 Warning: mysql_fetch_assoc() expects parameter 1 to be resource, null given in /var/www/index.php on line 161

Mindless

#3
Yeah to much for the end user to think about pmsl, really nobody should need told a basic obvious thing if thats the case i'd find another hobby lol.

ErikZown

You posted this in tbdev so i think you have to change those "$INSTALLER09" to "$TBDEV" .

Mindless

#1
Posted by devinkray - taken from johim, and enzo, modded to have the default noposter picture come up when nothing is posted

Reworked for Tbdev 09 :)
Code (sql) Select
ALTER TABLE torrents ADD `poster` varchar(255) character set utf8 collate utf8_bin NOT NULL default 'pic/noposter.jpg';


file - upload.php

under :
Code (php) Select
<tr>
      <td class='heading' valign='top' align='right'>{$lang['upload_torrent']}</td>
      <td valign='top' align='left'><input type='file' name='file' size='80' /></td>
      </tr>



add
Code (php) Select
<tr>
      <td class='heading' valign='top' align='right'>{$lang['upload_poster']}</td>
      <td valign='top' align='left'><input type='text' name='poster' size='80' /><br />{$lang['upload_poster1']}</td>
      </tr>



file lang/en/lang_upload.php add :
Code (php) Select
'upload_poster' => "Poster",
'upload_poster1' => "Direct link for a poster image to be shown on the details page",



file - takeupload.php

under :
Code (php) Select
if (!isset($_FILES["file"]))
      stderr($lang['takeupload_failed'], $lang['takeupload_no_formdata']);



add :
Code (php) Select
if (!empty($_POST['poster']))
    $poster = unesc($_POST['poster']);


Then add poster, poster, to the insert into torrents query
Code (php) Select
$ret = mysql_query("INSERT INTO torrents (search_text, filename,


to
Code (php) Select
$ret = mysql_query("INSERT INTO torrents (search_text, filename, poster,


same for , '".$poster."' :)
Code (php) Select
implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, $CURUSER["id"], "no",


to
Code (php) Select
implode(",", array_map("sqlesc", array(searchfield("$shortfname $dname $torrent"), $fname, '".$poster."', $CURUSER["id"], "no",


file - edit.php add :
Code (php) Select
$HTMLOUT .= tr($lang['edit_poster'], "<input type='text' name='poster' size='80' value='" . htmlspecialchars($row["poster"]) . "' alt='' /><br />{$lang['edit_poster1']}\n", 1);


file lang/en/lang_edit.php add :
Code (php) Select
'edit_poster' => "Poster",
'edit_poster1' => "Direct link for a poster image to be shown on the details page",



file takeedit.php add
Code (php) Select
$poster = $_POST["poster"];
$updateset[] = "poster = " . sqlesc($poster);



file details.php

add into the torrents query :
Code (php) Select
torrents.poster,


Then under :
Code (php) Select
if (!empty($row["descr"]))
$HTMLOUT .= "<tr><td style='vertical-align:top'>{$lang['details_description']}</td><td><div style='background-color:#d9e2ff;width:100%;height:150px;overflow: auto'>". str_replace(array("\n", "  "), array("<br />\n", "  "), format_comment( $row["descr"] ))."</div></td></tr>";



Add :
Code (php) Select
if (!empty($row["poster"]))
    $HTMLOUT .= tr("{$lang['details_poster']}", "<img src='".$row["poster"]."' alt='' />", 1);
    else
    $HTMLOUT .= tr("{$lang['details_poster']}", "<img src='{$TBDEV['baseurl']}/pic/noposter.jpg' alt='No poster' title='No poster available' />", 1);



file - lang/en/lang_details.php add
Code (php) Select
'details_poster' => "Poster",


finally for index to display it - adjust to your needs

Add to index or where ever
Code (php) Select
// 09 poster mod
    $query = "SELECT id, name, poster FROM torrents WHERE poster <> '' ORDER BY added DESC limit 15";
    $result = mysql_query( $query );
    $num = mysql_num_rows( $result );
    // count rows
    $HTMLOUT .="<script type='text/javascript' src='{$TBDEV['baseurl']}/scripts/scroll.js'></script>";
    $HTMLOUT .= "<div style='text-align:left;width:80%;border:1px solid blue;padding:5px;'><div style='background:lightgrey;height:25px;'><span style='font-weight:bold;font-size:12pt;'>{$lang['index_latest']}</span></div><br />
    <div style=\"overflow:hidden\">
    <div id=\"marqueecontainer\" onmouseover=\"copyspeed=pausespeed\" onmouseout=\"copyspeed=marqueespeed\">
    <span id=\"vmarquee\" style=\"position: absolute; width: 98%;\"><span style=\"white-space: nowrap;\">";
    $i = 20;
    while ( $row = mysql_fetch_assoc( $result ) ) {
        $id = (int) $row['id'];
        $name = htmlspecialchars( $row['name'] );
        $poster = htmlspecialchars( $row['poster'] );
        $name = str_replace( '_', ' ' , $name );
        $name = str_replace( '.', ' ' , $name );
        $name = substr( $name, 0, 50 );
        if ( $i == 0 )
        $HTMLOUT .= "</span></span><span id=\"vmarquee2\" style=\"position: absolute; width: 98%;\"></span></div></div><div style=\"overflow:hidden\">
        <div id=\"marqueecontainer\" onmouseover=\"copyspeed=pausespeed\" onmouseout=\"copyspeed=marqueespeed\"> <span id=\"vmarquee\" style=\"position: absolute; width: 98%;\"><span style=\"white-space: nowrap;\">
        <a href='{$TBDEV['baseurl']}/details.php?id=$id'><img src='" . htmlspecialchars( $poster ) . "' alt='$name' title='$name' width='100' height='120' border='0' /></a>";
        $i++;
    }
    $HTMLOUT .= "</span></span><span id=\"vmarquee2\" style=\"position: absolute; width: 98%;\"></span></div></div></div><br />\n";
    //== end 09 poster mod



save as scroll.js and upload to folder scripts
Code (html) Select
/***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=2 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.right)<(actualwidth*(-1)+4))
cross_marquee.style.right=(parseInt(cross_marquee2.style.right)+actualwidth+4)+"px"
if (parseInt(cross_marquee2.style.right)<(actualwidth*(-1)+4))
cross_marquee2.style.right=(parseInt(cross_marquee.style.right)+actualwidth+4)+"px"
cross_marquee2.style.right=parseInt(cross_marquee2.style.right)-copyspeed+"px"
cross_marquee.style.right=parseInt(cross_marquee.style.right)-copyspeed+"px"
}

function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee2=document.getElementById("vmarquee2")
cross_marquee.style.right=0
marqueewidth=document.getElementById("marqueecontainer").offsetWidth
actualwidth=cross_marquee.firstChild.offsetWidth
cross_marquee2.style.right=actualwidth+4+'px'
cross_marquee2.innerHTML=cross_marquee.innerHTML
setTimeout('righttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}

if (window.addEventListener)
window.addEventListener("load", initializemarquee, false)
else if (window.attachEvent)
window.attachEvent("onload", initializemarquee)
else if (document.getElementById)
window.onload=initializemarquee



And add this to your css files :)
#marqueecontainer{
position: relative;
width: 99%; /*marquee width - adjust to your design */
height: 120px; /*marquee height */
background-color:lightyellow;
color:black;
overflow: hidden;
border: 1px solid blue;
padding: 2px;
padding-left: 4px;
text-align:left;
}

#marqueecontainer img {
border-width:2px;
border-style:solid;
}



Thats it all updated and all Xhtml valid.

file - lang/en/lang_index.php add :
Code (php) Select
#index
'index_latest' => "Latest Torrents",



Upload noposter.jpg to pic folder and thats it - any improvements/updates please post so i can update the main post - any problems post them :-P
New Xhtml valid scroller created from Dynamic Drive scripts :)


Talibana requested this and because its an addon for poster mod there was no point in creating a new topic for it :)

Posted by putyn - Credits to putyn :)

Reworked For 09.
Xhtml valid.
Overlib replaced with wz_tooltip.

Code (php) Select
//== O9 Top ten torrents with tooltip poster
   $HTMLOUT .="<script type='text/javascript' src='{$TBDEV['baseurl']}/scripts/wz_tooltip.js'></script>";
   $HTMLOUT .="<div style='text-align:left;width:80%;border:1px solid blue;padding:5px;'>
   <div style='background:lightgrey;height:25px;'><span style='font-weight:bold;font-size:12pt;'>{$lang['index_latest']}</span></div><br />
   <table width='80%' border='1' cellpadding='10' cellspacing='0' align='center'>
   <tr><td align='center'>";
   $res = mysql_query("SELECT id, seeders, poster, leechers, name from torrents ORDER BY seeders + leechers DESC LIMIT 10 ") or sqlerr(__FILE__, __LINE__);
   if (mysql_num_rows($res) > 0) {
   $HTMLOUT .="<table align='center' class='tableinborder' border='2' cellspacing='0' cellpadding='5'>\n";
   $HTMLOUT .="<tr><td class='colhead'><b>[top 10 torrents]</b></td><td class='colhead'>Seeders</td><td class='colhead'>Leechers</td></tr>\n";
   while ($arr = mysql_fetch_assoc($res)) {
   $torrname = htmlspecialchars($arr['name']);
   if (strlen($torrname) > 35)
   $torrname = substr($torrname, 0,35) . "...";
   $poster = empty($arr["poster"]) ? "<img src=\'{$TBDEV['pic_base_url']}noposter.jpg\' width=\'150\' height=\'220\' />" : "<img src=\'".$arr['poster']."\' width=\'150\' height=\'220\' />";
   $HTMLOUT .="<tr><td class='tablea'><a href=\"{$TBDEV['baseurl']}/details.php?id=".$arr['id']."&amp;hit=1\" onmouseover=\"Tip('$poster');\" onmouseout=\"UnTip();\">".$torrname."</a></td><td >".$arr['seeders']."</td><td >".number_format($arr['leechers'])."</td></tr>\n";
   }
   $HTMLOUT .="</table>\n";
   } else
   $HTMLOUT .="no torrents here :(";
   $HTMLOUT .="</td><td style='width:15px;'></td>";
   $HTMLOUT .="<td align='center'>";
   $sql = "SELECT id, seeders, poster, leechers, name FROM torrents WHERE visible='yes' ORDER BY added DESC LIMIT 10";
   $result = mysql_query($sql) or sqlerr(__FILE__, __LINE__);
   if( mysql_num_rows($result) != 0 ){
   $HTMLOUT .="<table border='1' cellspacing='0' cellpadding='5'>";
   $HTMLOUT .="<tr>";
   $HTMLOUT .="<td class='colhead'><b>[last 10 torrents]</b></td>";
   $HTMLOUT .="<td class='colhead'>Seeders</td>";
   $HTMLOUT .="<td class='colhead'>Leechers</td>";
   $HTMLOUT .="</tr>";
   while( $arr = mysql_fetch_assoc($result) ){
   $torrname = htmlspecialchars($arr['name']);
   if (strlen($torrname) > 35)
   $torrname = substr($torrname, 0,35) . "...";
   $poster = empty($arr["poster"]) ? "<img src=\'{$TBDEV['pic_base_url']}noposter.jpg\' width=\'150\' height=\'220\' />" : "<img src=\'".$arr['poster']."\' width=\'150\' height=\'220\' />";
   $HTMLOUT .="<tr>";
   $HTMLOUT .="<td><a href=\"{$TBDEV['baseurl']}/details.php?id=".$arr['id']."&amp;hit=1\"></a><a href=\"{$TBDEV['baseurl']}/details.php?id=".$arr['id']."&hit=1\" onmouseover=\"Tip('$poster');\" onmouseout=\"UnTip();\">".$torrname."</a></td>";   
   $HTMLOUT .="<td align='left'>    " . $arr['seeders'] . "</td>";
   $HTMLOUT .="<td align='left'>    " . $arr['leechers'] . "</td>";   
   $HTMLOUT .="</tr>";
   }
   $HTMLOUT .="</table>";
   }
   $HTMLOUT .="</td></tr></table></div><br />";
   //== End 09 topten torrents



file - lang/en/lang_index.php add :
Code (php) Select
#index
'index_latest' => "Latest Torrents",



Next unrar and upload wz_tooltip to scripts folder, scroll.js is also included and thats it complete and styled to drop straight into your 09 source :)

Memcached version

Add to config.php :
   
Code (php) Select
$TBDEV['expires']['top5_torrents'] = 0; // 0 = infinite
$TBDEV['expires']['last5_torrents'] = 0; // 0 = infinite

   
   
   Add to index.php
   
   
Code (php) Select
//== O9 Top 5 and last5 torrents with tooltip
   $HTMLOUT .="<script type='text/javascript' src='{$TBDEV['baseurl']}/scripts/wz_tooltip.js'></script>";
   $HTMLOUT .="
   <div class='roundedCorners' style='text-align:left;width:80%;border:1px solid black;padding:5px;'>
   <div style='background:transparent;height:25px;'><span style='font-weight:bold;font-size:12pt;'>{$lang['index_latest']}</span></div>
   <br />
   <!--<a href=\"javascript: klappe_news('a4')\"><img border=\"0\" src=\"pic/plus.gif\" id=\"pica4\" alt=\"[Hide/Show]\" /></a><div id=\"ka4\" style=\"display: none;\">-->
   <table width='82%' border='2' cellpadding='10' cellspacing='0' align='center'>
   <tr><td align='center'>";
   $top5torrents = $mc1->get_value('top5_tor_');
   if($top5torrents === false ) {
   $res = mysql_query("SELECT id, seeders, poster, leechers, name from torrents ORDER BY seeders + leechers DESC LIMIT 5 ") or sqlerr(__FILE__, __LINE__);
   while ($top5torrent = mysql_fetch_assoc($res))
   $top5torrents[] = $top5torrent;
   $mc1->cache_value('top5_tor_', $top5torrents, $TBDEV['expires']['top5_torrents']);
   }
   if (count($top5torrents) > 0)
   {
   $HTMLOUT .="<table align='center' class='table' border='2' cellspacing='0' cellpadding='5'>\n";
   $HTMLOUT .="<tr><td class='colhead'><b>Top 5 torrents</b></td><td class='colhead'>Seeders</td><td class='colhead'>Leechers</td></tr>\n";
   if ($top5torrents)
   {
   foreach($top5torrents as $top5torrentarr) {
   $torrname = htmlspecialchars($top5torrentarr['name']);
   if (strlen($torrname) > 56)
   $torrname = substr($torrname, 0,56) . "...";
   $poster = empty($top5torrentarr["poster"]) ? "<img src=\'{$TBDEV['pic_base_url']}noposter.jpg\' width=\'150\' height=\'220\' />" : "<img src=\'".$top5torrentarr['poster']."\' width=\'150\' height=\'220\' />";
   $HTMLOUT .="<tr><td class='table'><a href=\"{$TBDEV['baseurl']}/details.php?id=".$top5torrentarr['id']."&amp;hit=1\" onmouseover=\"Tip('<b>Name:".$top5torrentarr['name']."</b><br /><b>Seeders:".$top5torrentarr['seeders']."</b><br /><b>Leechers:".$top5torrentarr['leechers']."</b><br />$poster');\" onmouseout=\"UnTip();\">".$torrname."</a></td><td >".$top5torrentarr['seeders']."</td><td >".number_format($top5torrentarr['leechers'])."</td></tr>\n";
   }
   $HTMLOUT .="</table><br /><br />\n";
   } else {
   //== If there are no torrents
   if (empty($top5torrents))
   $HTMLOUT .= "<tr><td colspan='4'>{$lang['latesttorrents_no_torrents']}</table><br />";
   }
   }
   //==Last 5 begin
   $last5torrents = $mc1->get_value('last5_tor_');
   if($last5torrents === false ) {
   $sql = "SELECT id, seeders, poster, leechers, name FROM torrents WHERE visible='yes' ORDER BY added DESC LIMIT 5";
   $result = mysql_query($sql) or sqlerr(__FILE__, __LINE__);
   while( $last5torrent = mysql_fetch_assoc($result) )
   $last5torrents[] = $last5torrent;
   $mc1->cache_value('last5_tor_', $last5torrents, $TBDEV['expires']['last5_torrents']);
   }
   if (count($last5torrents) > 0)
   {
   $HTMLOUT .="<table border='2' cellspacing='0' cellpadding='5'>";
   $HTMLOUT .="<tr>";
   $HTMLOUT .="<td class='colhead'><b>Last 5 torrents</b></td>";
   $HTMLOUT .="<td class='colhead'>Seeders</td>";
   $HTMLOUT .="<td class='colhead'>Leechers</td>";
   $HTMLOUT .="</tr>";
   if ($last5torrents)
   {
   foreach($last5torrents as $last5torrentarr) {
   $torrname = htmlspecialchars($last5torrentarr['name']);
   if (strlen($torrname) > 56)
   $torrname = substr($torrname, 0,56) . "...";
   $poster = empty($last5torrentarr["poster"]) ? "<img src=\'{$TBDEV['pic_base_url']}noposter.jpg\' width=\'150\' height=\'220\' />" : "<img src=\'".$last5torrentarr['poster']."\' width=\'150\' height=\'220\' />";
   $HTMLOUT .="<tr>";
   $HTMLOUT .="<td><a href=\"{$TBDEV['baseurl']}/details.php?id=".$last5torrentarr['id']."&amp;hit=1\"></a><a href=\"{$TBDEV['baseurl']}/details.php?id=".$last5torrentarr['id']."&amp;hit=1\" onmouseover=\"Tip('<b>Name:".$last5torrentarr['name']."</b><br /><b>Seeders:".$last5torrentarr['seeders']."</b><br /><b>Leechers:".$last5torrentarr['leechers']."</b><br />$poster');\" onmouseout=\"UnTip();\">".$torrname."</a></td>";   
   $HTMLOUT .="<td align='left'>".$last5torrentarr['seeders']."</td>";
   $HTMLOUT .="<td align='left'>".$last5torrentarr['leechers']."</td>";   
   $HTMLOUT .="</tr>";
   }
   $HTMLOUT .="</table>";
   } else {
   //== If there are no torrents
   if (empty($last5torrents))
   $HTMLOUT .= "<tr><td colspan='4'>{$lang['latesttorrents_no_torrents']}</table><br />";
   }
   }
   $HTMLOUT .="</td></tr></table></div><!--<div>--><br />";
   //== End 09 last5 and top5 torrents


file - lang/en/lang_index.php add :
Code (php) Select
#index
'index_latest' => "Latest Torrents",


add to download.php

Code (php) Select
$mc1->delete_value('top5_tor_');
  $mc1->delete_value('last5_tor_');


add to takeupload.php

Code (php) Select
$mc1->delete_value('top5_tor_');
  $mc1->delete_value('last5_tor_');