Crea sito

Vai al contenuto

"Questa qua è per te che sai sempre scegliere, io invece non ho scelta, te la devo scrivere. (Ligabue)"

- - - - -

Hack Thanks


  • Please log in to reply
Nessuna risposta a questa discussione

#1 Lethe

Lethe

    Advanced Member

  • Members
  • StellettaStellettaStelletta
  • 55 Messaggi:

Inviato 18 settembre 2010 - 09:41

Weila Ho realizzato uno script in grado di modificare un sistema automatico fatto in php, mi spiego meglio con questo script se potrà ottenere una modifica al vostro sito come anche SMF(forum) per avere i ringraziamenti dagli utenti.. testato e funzionante :grin:

<hack>
<file>
    <name>"database"</name>
    <operation>
      <action>"sql"</action>
      <data><![CDATA[CREATE TABLE `{$db_prefix}files_thanks` (
  `infohash` char(40) NOT NULL default '0',
  `userid` int(11) NOT NULL default '0',
  KEY `infohash` (`infohash`)
) TYPE=MyISAM;]]></data>
    </operation>
  </file>
  <file>
    <name>"$CURRENT_FOLDER/toCopy/thanks.php"</name>
    <operation>
      <action>"copy"</action>
      <where>"$DEFAULT_ROOT"</where>
      <data>"thanks.php"</data>
    </operation>
  </file>
  <file>
    <name>"$DEFAULT_LANGUAGE_PATH/lang_torrents.php"</name>
    <operation>
      <action>"add"</action>
      <search><![CDATA[?>]]></search>
      <where>"before"</where>
      <data><![CDATA[
$language["THANKS_BE_FIRST"]="Nobody thanks for this torrent, be the first!";
$language["THANKS_USERS"]="Who thanks";
$language["THANKS_YOU"]="Say Thank You!";
]]></data>
    </operation>
  </file>
  <file>
    <name>"$DEFAULT_STYLE_PATH/torrent.details.tpl"</name>
    <operation>
      <action>"add"</action>
      <search><![CDATA[</script>]]></search>
      <where>"before"</where>
      <data><![CDATA[

function disable_button(state)
{
 document.getElementById('ty').disabled=(state=='1'?true:false);
}

at=new sack();

function ShowUpdate()
{
  var mytext=at.response + '';
  var myout=mytext.split('|');
  document.getElementById('thanks_div').style.display='block';
  document.getElementById('loading').style.display='none';
  document.getElementById('thanks_div').innerHTML = myout[0]; //at.response;
  disable_button(myout[1]);
}

function thank_you(ia)
{
  disable_button('1');
  at.resetData();
  at.onLoading=show_wait;
  at.requestFile='thanks.php';
  at.setVar('infohash',"'"+ia+"'");
  at.setVar('thanks',1);
  at.onCompletion = ShowUpdate;
  at.runAJAX();
}

function ShowThank(ia)
{
  at.resetData();
  at.onLoading=show_wait;
  at.requestFile='thanks.php';
  at.setVar('infohash',"'"+ia+"'");
  at.onCompletion = ShowUpdate;
  at.runAJAX();
}

function show_wait()
{
  document.getElementById('thanks_div').style.display='none';
  document.getElementById('loading').style.display='block';
}

]]></data>
    </operation>
    <operation>
      <action>"add"</action>
      <search><![CDATA[<tr>
          <td align="right" class="header"><tag:language.INFO_HASH /></td>
          <td class="lista" align="center"><tag:torrent.info_hash /></td>
        </tr>
        <tr>]]></search>
      <where>"after"</where>
      <data><![CDATA[
          <td align="right" class="header" valign="top"><tag:language.THANKS_USERS /></td>
          <td class="lista" align="center">
              <form action="thanks.php" method="post" onsubmit="return false">
              <div id="thanks_div" name="thanks_div" style="display:block;"></div>
              <div id="loading" name="loading" style="display:none;"><img src="images/ajax-loader.gif" alt="" title="ajax-loader" /></div>
              <input type="button" id="ty" disabled="disabled" value="<tag:language.THANKS_YOU />" onclick="thank_you('<tag:torrent.info_hash />')" />
              </form>
              <script type="text/javascript">ShowThank('<tag:torrent.info_hash />');</script>
          </td>
        </tr>
        <tr>
]]></data>
    </operation>
  </file>
</hack>

Thanks.php
<?php

if (isset($_POST["infohash"]))
{

  $THIS_BASEPATH=dirname(__FILE__);
  require("$THIS_BASEPATH/include/functions.php");
  include(load_language("lang_torrents.php"));
  dbconn();

  $uid = intval(0+$CURUSER['uid']);
  $infohash=($_POST["infohash"]);

  $out="";

  $rt=mysql_query("SELECT uploader FROM {$TABLE_PREFIX}files WHERE info_hash=$infohash AND uploader=$uid");
  // he's not the uploader
  if (mysql_num_rows($rt)==0)
     $button=true;
  else
     $button=false;

  // saying thank you.
  if (isset($_POST["thanks"]) && $button)
  {
      mysql_free_result($rt);
      $rt=mysql_query("SELECT userid FROM {$TABLE_PREFIX}files_thanks WHERE userid=$uid AND infohash=$infohash");
      // never thanks for this file
      if (mysql_num_rows($rt)==0)
        {
           @mysql_query("INSERT INTO {$TABLE_PREFIX}files_thanks (infohash, userid) VALUES ($infohash, $uid)");
      }
  }

  mysql_free_result($rt);
  $rt=mysql_query("SELECT u.id, u.username, ul.prefixcolor, ul.suffixcolor FROM {$TABLE_PREFIX}files_thanks t LEFT JOIN
                   {$TABLE_PREFIX}users u ON u.id=t.userid LEFT JOIN {$TABLE_PREFIX}users_level ul ON u.id_level=ul.id WHERE infohash=$infohash");
  if (mysql_num_rows($rt)==0)
     $out=$language["THANKS_BE_FIRST"];


  while ($ty=mysql_fetch_assoc($rt))
    {
      if ($ty["id"]==$uid) // already thank
        $button=false;
      $out.="<a href=\"$BASEURL/index.php?page=userdetails&amp;id=".$ty["id"]."\">".unesc($ty["prefixcolor"].$ty["username"].$ty["suffixcolor"])."</a>&nbsp;";
  }
  if ($button && $CURUSER["uid"]>1)
     $out.="|0";
  else
     $out.="|1";

}
else
  $out= "no direct access!";

echo $out;
die;
?>




Similar Topics Collapse

  Discussione Forum Iniziata da Statistiche Informazioni ultimo messaggio


1 utente(i) stanno leggendo questa discussione

0 members, 1 guests, 0 anonymous users