Need some help in Perl having errors.

Discussion in 'Programming' started by Egrift Inc, Apr 15, 2013.

  1. #1
    Currently having a issue for a file download site.


    Currently theres a bandwidth limit for the file download which also allows embedding videos. Once the limit of bandwidth is reached instead of the file download on the download page it says this : You have reached the download limit for today.<br> You can either wait till tomorrow to view or Upgrade now over here:


    But apparently the embed video page doesnt have the limit so users can by pass it.


    The limit code is this for Perl :

    sub DownloadChecks
    {
      my ($file) = @_;
     
      if($c->{bw_limit})
      {
          my $cond = $ses->getUser && $ses->getUser->{premium} ? "usr_id=".$ses->getUserId : "ip=INET_ATON('".$ses->getIP."')";
          my $bw = $db->SelectOne("SELECT SUM(size) FROM IP2Files WHERE $cond AND created > NOW()-INTERVAL ? DAY",$c->{bw_limit_days});
          $file->{message} = "You have reached the download limit for today.<br> You can either wait till tomorrow to view or Upgrade now over here: <a href=http://grifthost.com/premium.html target=_blank>Click</a>"
            if ($bw > 1024*1024*$c->{bw_limit});
      }
    Code (markup):




    and the embed code is this :

    sub VideoEmbed
    {
      #print"Content-type:text/html\n\n";
      return print("Content-type:text/html\n\nVideo mod is disabled") unless $c->{m_v};
      my $file = $db->SelectRow("SELECT f.*, s.*, u.usr_id, UNIX_TIMESTAMP(usr_premium_expire)-UNIX_TIMESTAMP() as exp_sec
                                  FROM (Files f, Servers s)
                                  LEFT JOIN Users u ON f.usr_id = u.usr_id
                                  WHERE f.file_code=?
                                  AND f.srv_id=s.srv_id",$f->{file_code});
      return print("Content-type:text/html\n\nFile was deleted") unless $file;
      my $utype2 = $file->{usr_id} ? ($file->{exp_sec}>0 ? 'prem' : 'reg') : 'anon';
      return print("Content-type:text/html\n\nVideo embed restricted for this user") unless $c->{"video_embed_$utype2"};
      $file = &VideoMakeCode($file,1)||return;
      return print("Content-type:text/html\n\nCan't create video code") unless $file->{video_code};
      $file->{video_ads}=$c->{m_a};
      $ses->{form}->{no_hdr}=1;
      DownloadTrack($file);
      $db->Exec("UPDATE Files SET file_views=file_views+1 WHERE file_id=?",$file->{file_id});
      return $ses->PrintTemplate("video_embed.html",%$file);
    }
    Code (markup):
    Also both codes are on the same file.

    Is there a way to put the limiter code into the embed code? so that message also pops up when the limit is reached? Thanks any help would be appreciated.
     
    Egrift Inc, Apr 15, 2013 IP