Download limit
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Download limit

Started by Casb++, 27 January, 2004, 01:09:51

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Casb++

Hi out there.

Can somebody make a script where unreg users only can download  xx Mb/Gb and reg. user can download unlimited.
Can anyone translate this script to lua.

'Webstats script 0.31 by Gadget
'This script needs html template, which should be included in same zip file
'You can use what kind of html file you like to, see included file for replacable strings
'Use web server on local computer or network see http://www.apache.org for www server if you need one
'or upload your stats page with ftp, script uses ftp.exe located on your system32 folder.
'If script gives errors on first start, try to reset it couple of times.
'
'Filenames are relative to dchub folder, files should be placed as follows:
'
'webstats.script (this file) -> C:\Program files\Direct Connect Hub\scripts
'template.htm (template www page) -> C:\Program files\Direct Connect Hub
'index.htm (local www page) -> If you use ftp, C:\Program files\Direct Connect Hub is enough, otherwise your shared web folder
'image files -> To 'images' subfolder to your web server
'
'Thanks for FLiXD of his rainbow obsession, and other motivators at http://dc.ww-ei.com

Dim clsStats,iUpdateInterval,iChatLines,iTicker,sTemplateFile,sOutputFile,sSettingsFile,sStatsStart
Dim iUserH(23),iUserW(6),iChatH(23),iChatW(23),iPacket(11),iPeakUsers,sPeakTime,iPeakShare,iStatHour,iStatWeekday
Dim sTemplate,sStartup,sShutdown,sStatus,sChat,iResets,iBoots,iCrashes,iUptime,iPackets,sReset,iLogins,iKicks,iRedirects
Dim bUseFtp,sFtpBatchFile,sFtpLogFile,sFtpAddress,sFtpUsername,sFtpPassword

Sub Main

  iUpdateInterval = 1                 '<- In minutes
  iChatLines      = 25                 '<- How many chat lines will be shown
  sTemplateFile   = "C:\wwwroot\template.htm"     '<- Path to www template file (file must be found)
  sOutputFile     = "C:\wwwroot\index.htm" '<- Path to www output file (script creates this file)
  sSettingsFile   = "C:\wwwroot\StatSettings.txt" '<- Path to settings file (script creates this file)
  bUseFtp         = True               '<- True if you want to use FTP upload, False if not
  sFtpBatchFile   = "C:\wwwroot\FtpBatch.txt"     '<- Local batch file for ftp.exe (script creates this file)
  sFtpLogFile     = "C:\wwwroot\FtpLog.txt"       '<- Local file for FTP log, read this file if something goes wrong
  sFtpAddress     = "hjem.get2net.dk/index.htm" '<- Where to send the page (path must exist)
  sFtpUsername    = "xxxxxxxx"    '<- Your FTP username
  sFtpPassword    = "xxxxxxxxx"    '<- Your FTP password

  tmrScriptTimer.Interval = 60000
  tmrScriptTimer.Enabled = True
  iTicker=iUpdateInterval
  Set clsStats=New cStats
End Sub

Sub tmrScriptTimer_Timer
  iUptime=iUptime+tmrScriptTimer.Interval/1000
  sReset=CStr(Now)
  CheckPeaks
  iTicker=iTicker+1
  If iTicker>iUpdateInterval Then
    SaveStats
    iTicker=0
  End If
End Sub

Sub NewUserConnected(curUser)
  iLogins=iLogins+1
  CheckPeaks
End Sub

Sub OpConnected(curUser)
  iLogins=iLogins+1
  CheckPeaks
End Sub

Sub DataArival(curUser,sCurData)
  iPackets=iPackets+1
  If Left(sCurData,1)="<" Then
    iPacket(0)=iPacket(0)+1
    If iStatHour<>Hour(Now) Then
      iStatHour=Hour(Now)
      iChatH(iStatHour)=0
    End If
    iChatH(iStatHour)=iChatH(iStatHour)+1
    If iStatWeekday<>Weekday(Now)-1 Then
      iStatWeekday=Weekday(Now)-1
      iChatW(iStatWeekday)=0
    End If
    iChatW(iStatWeekday)=iChatW(iStatWeekday)+1
    sChat=sChat+vbCrLf+"["+sFmtTime(Now)+"] "+sCurData
    Do While UBound(Split(sChat,vbCrLf))>iChatLines
      sChat=Mid(sChat,InStr(sChat,vbCrLf)+2)
    Loop
  ElseIf Left(sCurData,4)="$To:" Then
    iPacket(1)=iPacket(1)+1
    If curUser.bOperator And InStr(sCurData,"You are being kicked because: ")>1 Then iKicks=iKicks+1
  ElseIf Left(sCurData,4)="$Sea" Then
    iPacket(2)=iPacket(2)+1
  ElseIf Left(sCurData,4)="$SR " Then
    iPacket(3)=iPacket(3)+1
  ElseIf Left(sCurData,4)="$Con" Then
    iPacket(4)=iPacket(4)+1
  ElseIf Left(sCurData,4)="$Rev" Then
    iPacket(5)=iPacket(5)+1
  ElseIf Left(sCurData,5)="$GetI" Then
    iPacket(6)=iPacket(6)+1
  ElseIf Left(sCurData,4)="$MyI" Then
    iPacket(7)=iPacket(7)+1
  ElseIf Left(sCurData,5)="$GetN" Then
    iPacket(8)=iPacket(8)+1
  ElseIf Left(sCurData,4)="$Ver" Then
    iPacket(9)=iPacket(9)+1
  ElseIf sCurData="" Then
    iPacket(10)=iPacket(10)+1
  Else
    If curUser.bOperator And Left(sCurData,12)="$OpForceMove" Then iRedirects=iRedirects+1
    iPacket(11)=iPacket(11)+1
  End If
End Sub

Sub LoadStats
  On Error Resume Next
  Set fs=CreateObject("Scripting.FileSystemObject")
  If fs.FileExists(sSettingsFile) Then
    Set ReadFile=fs.OpenTextFile(sSettingsFile,1,True)
    sStatsStart=ReadFile.ReadLine
    sStartup=ReadFile.ReadLine
    sShutdown=ReadFile.ReadLine
    sStatus=ReadFile.ReadLine
    iStatWeekday=CDBl(ReadFile.ReadLine)
    iStatHour=CDbl(ReadFile.ReadLine)
    iResets=CDbl(ReadFile.ReadLine)
    iBoots=CDbl(ReadFile.ReadLine)
    iCrashes=CDbl(ReadFile.ReadLine)
    iUptime=CDbl(ReadFile.ReadLine)
    iPackets=CDbl(ReadFile.ReadLine)
    iLogins=CDbl(ReadFile.ReadLine)
    iKicks=CDbl(ReadFile.ReadLine)
    iRedirects=CDbl(ReadFile.ReadLine)
    For i=0 to 23:iUserH(i)=CDbl(ReadFile.ReadLine):Next
    For i=0 to 6:iUserW(i)=CDbl(ReadFile.ReadLine):Next
    For i=0 to 23:iChatH(i)=CDbl(ReadFile.ReadLine):Next
    For i=0 to 6:iChatW(i)=CDbl(ReadFile.ReadLine):Next
    For i=0 to 11:iPacket(i)=CDbl(ReadFile.ReadLine):Next
    sChat=Replace(ReadFile.ReadLine,"
",vbCrLf)
    ReadFile.Close
  End If
  If sStatsStart="" Then sStatsStart=CStr(Now)
  If fs.FileExists(sTemplateFile) Then
    Set ReadFile=fs.OpenTextFile(sTemplateFile,1,True)
    sTemplate=ReadFile.ReadAll
    ReadFile.Close
  Else
    MsgBox "Template www stats file not found!"
  End If
End Sub

Sub SaveStats
  Set fs=CreateObject("Scripting.FileSystemObject")
  Set WriteFile = fs.OpenTextFile(sSettingsFile, 2, True)
  WriteFile.WriteLine(sStatsStart)
  WriteFile.WriteLine(sStartup)
  WriteFile.WriteLine(sShutdown)
  WriteFile.WriteLine(sStatus)
  WriteFile.WriteLine(CStr(iStatWeekday))
  WriteFile.WriteLine(CStr(iStatHour))
  WriteFile.WriteLine(CStr(iResets))
  WriteFile.WriteLine(CStr(iBoots))
  WriteFile.WriteLine(CStr(iCrashes))
  WriteFile.WriteLine(CStr(iUptime))
  WriteFile.WriteLine(CStr(iPackets))
  WriteFile.WriteLine(CStr(iLogins))
  WriteFile.WriteLine(CStr(iKicks))
  WriteFile.WriteLine(CStr(iRedirects))
  For i=0 to 23:WriteFile.WriteLine(CStr(iUserH(i))):Next
  For i=0 to 6:WriteFile.WriteLine(CStr(iUserW(i))):Next
  For i=0 to 23:WriteFile.WriteLine(CStr(iChatH(i))):Next
  For i=0 to 6:WriteFile.WriteLine(CStr(iChatW(i))):Next
  For i=0 to 11:WriteFile.WriteLine(CStr(iPacket(i))):Next
  WriteFile.WriteLine(Replace(sChat,vbCrLf,"
"))
  WriteFile.Close
  CheckPeaks
  If colUsers.count>0 Then
    iSharePerUser=colUsers.iTotalBytesShared/colUsers.count
  Else
    iSharePerUser=0
  End If
  sTxt=sTemplate
  sTxt=Replace(sTxt,"%HUBNAME%",frmHub.txtName)
  sTxt=Replace(sTxt,"%HUBADDRESS%",frmHub.txtIP)
  sTxt=Replace(sTxt,"%HUBDESCRIPTION%",frmHub.txtDescription)
  sTxt=Replace(sTxt,"%HUBSTATUS%",sStatus)
  sTxt=Replace(sTxt,"%DATE%",CStr(Now))
  sTxt=Replace(sTxt,"%USERS%",CStr(colUsers.count))
  sTxt=Replace(sTxt,"%MAXUSERS%",CStr(frmHub.sldrMaxUsers))
  sTxt=Replace(sTxt,"%PEAKUSERS%",CStr(iPeakUsers))
  sTxt=Replace(sTxt,"%PEAKTIME%",sPeakTime)
  sTxt=Replace(sTxt,"%SHARED%",sSuffix(colUsers.iTotalBytesShared))
  sTxt=Replace(sTxt,"%SHAREPERUSER%",sSuffix(iSharePerUser))
  sTxt=Replace(sTxt,"%PEAKSHARE%",sSuffix(iPeakShare))
  sTxt=Replace(sTxt,"%WELCOMEMESSAGE%",sStripTags(frmHub.txtOnjoin))
  For i=0 To 23
    If iUserH(i)=>iMaxUH Then iMaxUH=iUserH(i)
    If iChatH(i)=>iMaxCH Then iMaxCH=iChatH(i)    
  Next
  For i=0 To 6
    If iUserW(i)=>iMaxUW Then iMaxUW=iUserW(i)
    If iChatW(i)=>iMaxCW Then iMaxCW=iChatW(i)    
  Next
  For i=0 To 11
    If iPacket(i)=>iMaxP Then iMaxP=iPacket(i)
  Next
  If iMaxUH<1 Then iMaxUH=1
  If iMaxCH<1 Then iMaxCH=1
  If iMaxUW<1 Then iMaxUW=1
  If iMaxCW<1 Then iMaxCW=1
  If iMaxP<1 Then iMaxP=1
  For i=0 To 23
    sTxt=Replace(sTxt,"%USERH"+CStr(i)+"%",CStr(iUserH(i)+0))
    sTxt=Replace(sTxt,"%PUSERH"+CStr(i)+"%",CStr(Int(iUserH(i)/iMaxUH*100)))
    sTxt=Replace(sTxt,"%CHATH"+CStr(i)+"%",CStr(iChatH(i)+0))
    sTxt=Replace(sTxt,"%PCHATH"+CStr(i)+"%",CStr(Int(iChatH(i)/iMaxCH*100)))
  Next
  For i=0 To 6
    sTxt=Replace(sTxt,"%USERW"+CStr(i)+"%",CStr(iUserW(i)+0))
    sTxt=Replace(sTxt,"%PUSERW"+CStr(i)+"%",CStr(Int(iUserW(i)/iMaxUW*100)))
    sTxt=Replace(sTxt,"%CHATW"+CStr(i)+"%",CStr(iChatW(i)+0))
    sTxt=Replace(sTxt,"%PCHATW"+CStr(i)+"%",CStr(Int(iChatW(i)/iMaxCW*100)))
  Next
  For i=0 To 11
    sTxt=Replace(sTxt,"%PACKET"+CStr(i)+"%",CStr(iPacket(i)+0))
    sTxt=Replace(sTxt,"%PPACKET"+CStr(i)+"%",CStr(Int(iPacket(i)/iMaxP*100)))
  Next
  For Each oUser In colUsers
    If oUser.bOperator Then
      sOpList=sOpList+oUser.sName+" "
    Else
      sUserList=sUserList+oUser.sName+" "
    End If
  Next
  For  lPos= 1 To frmHub.lstOps.ListItems.Count
    If frmHub.lstOps.ListItems.Item(lPos).SubItems(2)="True" Then
      iOps=iOps+1
    ElseIf Left(frmHub.lstOps.ListItems.Item(lPos).SubItems(1),6)="Banned" Then
      iBanned=iBanned+1
    Else
      iRegs=iRegs+1
    End If
  Next
  iUptime=iUptime+DateDiff("s",sReset,Now)
  If iUptime<1 Then iUptime=1
  sReset=CStr(Now)
  sTxt=Replace(sTxt,"%STARTUP%",sStartup)
  sTxt=Replace(sTxt,"%STATSSTARTED%",sStatsStart)
  sTxt=Replace(sTxt,"%STATSTIME%",FmtSeconds(DateDiff("s",sStatsStart,Now)))
  sTxt=Replace(sTxt,"%OPLIST%",sOpList)
  sTxt=Replace(sTxt,"%USERLIST%",sUserList)
  sTxt=Replace(sTxt,"%CHAT%",sStripTags(sChat))
  sTxt=Replace(sTxt,"%KICKED%",CStr(iKicks+0))
  sTxt=Replace(sTxt,"%KICKEDPERDAY%",CStr(CCur(iKicks/(iUptime/86400))))
  sTxt=Replace(sTxt,"%REDIRECTED%",CStr(iRedirects+0))
  sTxt=Replace(sTxt,"%REDIRECTEDPERDAY%",CStr(CCur(iRedirects/(iUptime/86400))))
  sTxt=Replace(sTxt,"%BANNED%",CStr(frmHub.lstPermBan.ListCount)+" by IP, "+CStr(iBanned+0)+" by name")
  sTxt=Replace(sTxt,"%REGUSERS%",CStr(iRegs+0))
  sTxt=Replace(sTxt,"%REGOPS%",CStr(iOps+0))
  sTxt=Replace(sTxt,"%RESETS%",CStr(iResets+0))
  sTxt=Replace(sTxt,"%BOOTS%",CStr(iBoots+0))
  sTxt=Replace(sTxt,"%CRASHES%",CStr(iCrashes+0))
  sTxt=Replace(sTxt,"%UPTIME%",FmtSeconds(iUptime))
  sTxt=Replace(sTxt,"%DOWNTIME%",FmtSeconds(DateDiff("s",sStatsStart,Now)-iUptime))
  sTxt=Replace(sTxt,"%RELIABILITY%",CStr(CCur(iUptime/DateDiff("s",sStatsStart,Now)*100))+" %")
  sTxt=Replace(sTxt,"%PACKETS%",CStr(iPackets+0))
  sTxt=Replace(sTxt,"%PACKETSPERMINUTE%",CStr(CCur(iPackets/(iUptime/60))))
  sTxt=Replace(sTxt,"%TRAFFIC%",Replace(frmHub.stsHub.Panels(2).Text,"Traffic: ",""))
  sTxt=Replace(sTxt,"%LOGINS%",CStr(iLogins+0))
  sTxt=Replace(sTxt,"%GENERATOR%","http://gadget.no-ip.info"+Chr(34)+">Webstats.script 0.31 by Gadget")
  Set Writefile = fs.OpenTextFile(sOutputFile, 2, True)
  WriteFile.WriteLine(sTxt)
  WriteFile.Close
  If bUseFtp Then
    aFtp=Split(sFtpAddress,"/")
    If UBound(aFtp)>0 Then
      Set WriteFile = fs.OpenTextFile(sFtpBatchFile, 2, True)
      WriteFile.WriteLine("open "+aFtp(0))
      WriteFile.WriteLine(sFtpUsername)
      WriteFile.WriteLine(sFtpPassword)
      If UBound(aFtp)>1 Then
        For i=1 To UBound(aFtp)-1
          WriteFile.WriteLine("cd "+aFtp(i))
        Next
      End If
      WriteFile.WriteLine("ascii")
      WriteFile.WriteLine("put "+Chr(34)+sOutputFile+Chr(34)+" "+Chr(34)+aFtp(UBound(aFtp))+Chr(34))
      WriteFile.WriteLine("quit")
      WriteFile.Close
      Set ws=CreateObject("WScript.Shell")
      ws.Run "%comspec% /c ftp -i -s:"+sFtpBatchFile+" >"+sFtpLogFile, 0, True
    End If
  End If
End Sub

Part 1

Casb++

Class cStats
  Sub Class_Initialize
    LoadStats
    If sShutdown="-" Then
      iCrashes=iCrashes+1
      sStartup=CStr(Now)
    ElseIf DateDiff("s",sShutdown,Now)<5 Then
      iResets=iResets+1
    Else
      iBoots=iBoots+1
      sStartup=CStr(Now)
    End If
    sStatus="Online, started "+sStartup
    sShutdown="-"
    sReset=CStr(Now)
    SaveStats
  End Sub
  Sub Class_Terminate
    iUptime=iUptime+DateDiff("s",sReset,Now)
    sShutdown=CStr(Now)
    sStatus="Offline, shutdown "+sShutdown
    SaveStats
  End Sub
End Class

Function sSuffix(iShare)
  If iShare<1024 Then
    sSuffix=CStr(iShare)+" bytes"
  ElseIf iShare<1024^2 Then
    sSuffix=CStr(CCur(iShare/1024))+" kB"
  ElseIf iShare<1024^3 Then
    sSuffix=CStr(CCur(iShare/1024^2))+" MB"
  ElseIf iShare<1024^4 Then
    sSuffix=CStr(CCur(iShare/1024^3))+" GB"
  Else
    sSuffix=CStr(CCur(iShare/1024^4))+" TB"
  End If
End Function

Sub CheckPeaks
  If iStatHour<>Hour(Now) Then
    iStatHour=Hour(Now)
    iChatH(iStatHour)=0
    iUserH(iStatHour)=0
  End If
  If iStatWeekday<>Weekday(Now)-1 Then
    iStatWeekday=Weekday(Now)-1
    iChatW(iStatWeekday)=0
    iUserW(iStatWeekday)=0
  End If
  If iPeakShare<=colUsers.iTotalBytesShared Then iPeakShare=colUsers.iTotalBytesShared
  If iPeakUsers<=colUsers.Count Then
    iPeakUsers=colUsers.Count
    sPeakTime=CStr(Now)
  End If
  If iUserH(Hour(Now))<=colUsers.Count Then iUserH(Hour(Now))=colUsers.Count
  If iUserW(Weekday(Now)-1)<=colUsers.Count Then iUserW(Weekday(Now)-1)=colUsers.Count
End Sub

Function FmtSeconds(iSeconds)
  iSec=iSeconds
  iYears=Int(iSec/60/60/24/365):iSec=iSec-iYears*60*60*24*365
  iMonths=Int(iSec/60/60/24/30):iSec=iSec-iMonths*60*60*24*30
  iDays=Int(iSec/60/60/24):iSec=iSec-iDays*60*60*24
  iHours=Int(iSec/60/60):iSec=iSec-iHours*60*60
  iMinutes=Int(iSec/60):iSec=iSec-iMinutes*60
  If iYears>0 Then FmtSeconds=CStr(iYears)+" years, "
  If iMonths>0 Then FmtSeconds=FmtSeconds+CStr(iMonths)+" months, "
  If iDays>0 Then FmtSeconds=FmtSeconds+CStr(iDays)+" days, "
  If iHours>0 Then FmtSeconds=FmtSeconds+CStr(iHours)+" hours, "
  If iMinutes>0 Then FmtSeconds=FmtSeconds+CStr(iMinutes)+" minutes, "
  FmtSeconds=FmtSeconds+CStr(iSec)+" seconds"
End Function

Function sStripTags(sString)
  sStripTags=Replace(sString,"<","<")
  sStripTags=Replace(sStripTags,">",">")
  sStripTags=Replace(sStripTags,vbCrLf,"
"+vbCrLf)
  sStripTags=Replace(sStripTags," "," ")
End Function

Function sFmtTime(sTime)
  sFmtTime=CStr(Minute(sTime))
  If Len(sFmtTime)<2 Then sFmtTime="0"+sFmtTime
  sFmtTime=CStr(Hour(sTime))+":"+sFmtTime
  If Len(sFmtTime)<5 Then sFmtTime="0"+sFmtTime
End Function

[NL]Pur

Can somebody make a script where unreg users only can download xx Mb/Gb and reg. user can download unlimited. 
Can anyone translate this script to lua.


can't be done

kepp

Well, the translation can be done..
Guarding    

Casb++

QuoteWell, the translation can be done..
Nice. Is it something you can make, i would be greatful because thats the only script i need to run PtokaX 100%

kepp

off for work so i will see what i can do, Can't Upload it via FTP from lua Though,
Guarding    

SMF spam blocked by CleanTalk