Главная страница


ru.website

 
 - RU.WEBSITE -------------------------------------------------------------------
 From : Ilia Kantor                          2:5020/1815.6  26 May 2001  00:15:30
 To : Artur Shevtsov
 Subject : Счетчик скачивания
 -------------------------------------------------------------------------------- 
 
  Здоровеньки булы, Artur Shevtsov!
 
  AS> Интересует сабж.
  AS> Хочется, чтобы при клике на ссылку начиналось скачивание файла, и
  AS> одновременно отрабатывал Перловый скрипт-счетчик. Как такое
  AS> реализовать? Т.е конструкция <a href="http:/aaa.txt">скачать</a> запустит
  AS> скачивание, как к ней привязать запуск скрипта? Может Ява аплет?
 
  AS> Вариант, запускать предварительную страницу и считать кол-во заходов на
  AS> нее не устраивает, хочется более красивое решение.
 
  Вот скpипт и пpимеp HTML...  по ходу pазбеpешься что к чему:  that's easy.
  Фишка в том, чтобы ссылку не на файл, а на скpипт ставить. Адpес - как
 паpаметp. Работает без всяких конфигов сеpвеpа, даже и не с Apache.
 
 === Cut ===
 <html>
 
 <head>
 <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
 <title>Example of using DownloadCounter script</title>
 <script language="JavaScript">
 <!--
 function show(txt){
   window.status = txt;
 }
 
 function hide(){
   window.status="";
 }
 
 // -->
 
 </script>
 </head>
 
 <body>
 
 <p><b>Example of using DownloadCounter script.</b></p>
 
 <p><a href="http://xacker.virtualave.net/cgi-bin/load.pl?../perl/downloadcounte 
 r.zip"
 
 >DownloadCounter script</a> -
 
 downloads: <!--#include
 virtual="http://xacker.virtualave.net/cgi-bin/showload.pl?../perl/downloadcount 
 er.zip" --></p>
 
 <p><em>See HTML code of this page.</em></p>
 
 <hr>
 
 <p><b>Java Script optimized (See browser status line):</b></p>
 
 <p><a
 href="http://xacker.virtualave.net/cgi-bin/load.pl?../perl/downloadcounter.zip" 
 onMouseOver="show('Download Counter (ZIP archive)');return true"
 onMouseOut="hide()">DownloadCounter script</a> -
 downloads: <!--#include
 virtual="http://xacker.virtualave.net/cgi-bin/showload.pl?../perl/downloadcount 
 er.zip" --></p>
 
 <p><em>See HTML code of this page.</em></p>
 
 <hr>
 
 <p>Copyright й 1999 by <a href="mailto:xacker@phreaker.net">Aleksey
 Xacker</a><br>
 Visit my Homepage: <a
 href="http://xacker.virtualave.net">http://xacker.virtualave.net</a></p>
 </body>
 </html>
 === Cut ===
 === Cut ===
 #!/usr/bin/perl
 ##############################################################################
 # Download Counter (LOAD)         Version 2.5                                #
 # Copyright 1998 Aleksey Xacker   xacker@phreaker.net                        #
 #       http://xacker.virtualave.net               #
 # Created 3.XII.1998              Last Modified 8.IV.1999                    #
 ##############################################################################
 # COPYRIGHT NOTICE                                                           #
 # Copyright 1998 Aleksey Xacker All Rights Reserved.                         #
 #                                                                            #
 # Download Counter may be used and modified free of charge by anyone so long #
 # as this copyright notice and the comments above remain intact. By using    #
 # this code you agree to indemnify Aleksey Xacker from any liability that    #
 # might arise from it's use.                                                 #
 #                                                                            #
 # Selling the code for this program without prior written consent is         #
 # expressly forbidden. In other words, please ask first before you try and   #
 # make money off of my program.                                              #
 #                                                                            #
 # Obtain permission before redistributing this software over the Internet or #
 # in any other medium.In all cases copyright and header must remain intact.  #
 ##############################################################################
 # Set Variables
 $databasefile = '../download.txt';
 
 # Get the input
 $link = $ENV{'QUERY_STRING'};
 
 # Bypass GetRight bug like ../exe/filename.exe/../exe/ ...
 $len = length($link);
 for ($i=0;$i<$len;$i++){
   $ch = substr($link, $i, 3);
   if ($ch eq '/..') {
    if (substr($link, $i - 1, 1) ne '.') {
     $link = substr($link, $i + 1, $len - $i);
     $len = length($link);
     $i = 0;
    }
   }
   if ($ch eq '\..') {
    if (substr($link, $i - 1, 1) ne '.') {
     $link = substr($link, $i + 1, $len - $i);
     $len = length($link);
     $i = 0;
    }
   }
 }
 
 # Begin Code
 open(FILE, $databasefile) || die Can't locate database file $!;
 flock(FILE, 2); # blocking write lock
 @DATA = <FILE>;
 flock(FILE, 8);
 close(FILE);
 $SIZE = @DATA;
 
 for ($i=0;$i<$SIZE;$i++) {
    ($counter, $baselink) = split(/'/, $DATA[$i]);
    chop($baselink);
    if ($baselink eq $link) {
     &UpdateStats;
    }
 }
 
 # Add new link to database file
 open(FILE, ">>$databasefile") || die Can't locate database file $!;
 flock(FILE, 2); # blocking write lock
 print FILE "1'$link\n"; # First time
 flock(FILE, 8);
 close(FILE);
 
 &LocateLink;
 
 # Increase through-link counter
 sub UpdateStats {
    @DATA = sort {($b =~ /(\d+)/)[0] <=> ($a =~ /(\d+)/)[0]} @DATA;
    $counter++;
 
    open(FILE, ">$databasefile") || die Can't locate database file $!;
    flock(FILE, 2); # blocking write lock
    for ($j=0;$j<$SIZE;$j++) {
       if ($j eq $i) {
         print FILE "$counter'$link\n";
       }
       else {
         print FILE "$DATA[$j]";
       }
    }
    flock(FILE, 8);
    close(FILE);
 
    &LocateLink;
 }
 
 sub LocateLink {
   print "Location: $link\n\n";
   exit;
 } === Cut ===
    The soldiers passing by, listening to the wind of change..
                  [Team Scorpions - Rulezzz FOREVER!] [Team Metallica - COOL.]
 --- GoldEd 3.00.Alpha4+
  * Origin: Алгоритмы, методы, исходники http://algolist.da.ru (2:5020/1815.6)
 
 

Вернуться к списку тем, сортированных по: возрастание даты  уменьшение даты  тема  автор 

 Тема:    Автор:    Дата:  
 Счетчик скачивания   Artur Shevtsov   23 May 2001 10:16:46 
 Счетчик скачивания   Alexander Orlov   24 May 2001 11:01:04 
 Счетчик скачивания   Besogonov Alex   28 May 2001 19:50:30 
 Счетчик скачивания   Alexander Orlov   02 Jun 2001 20:29:42 
 Re: Счетчик скачивания   Oleg Bykov   04 Jun 2001 08:49:50 
 Счетчик скачивания   Besogonov Alex   28 May 2001 19:01:15 
 Счетчик скачивания   Ilia Kantor   26 May 2001 00:15:30 
Архивное /ru.website/39463b0ef5ad.html, оценка 2 из 5, голосов 10
Яндекс.Метрика
Valid HTML 4.01 Transitional