A PHP Error was encountered
Severity: 8192
Message:  Function create_function() is deprecated
Filename: geshi/geshi.php
Line Number: 4698
	Backtrace:
	
		
	
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
			Line: 4698
			Function: _error_handler			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
			Line: 4621
			Function: _optimize_regexp_list_tokens_to_string			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
			Line: 1655
			Function: optimize_regexp_list			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
			Line: 2029
			Function: optimize_keyword_group			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/geshi/geshi.php
			Line: 2168
			Function: build_parse_cache			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/libraries/Process.php
			Line: 45
			Function: parse_code			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/models/Pastes.php
			Line: 517
			Function: syntax			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
			Line: 624
			Function: getPaste			
		
	
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
			Line: 315
			Function: require_once			
		
	
 
A PHP Error was encountered
Severity: Warning
Message:  Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/system/core/Exceptions.php:271)
Filename: view/download.php
Line Number: 2
	Backtrace:
	
		
	
		
	
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/themes/geocities/views/view/download.php
			Line: 2
			Function: header			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
			Line: 173
			Function: include			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
			Line: 43
			Function: _ci_load			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
			Line: 625
			Function: view			
		
	
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
			Line: 315
			Function: require_once			
		
	
 
A PHP Error was encountered
Severity: Warning
Message:  Cannot modify header information - headers already sent by (output started at /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/system/core/Exceptions.php:271)
Filename: view/download.php
Line Number: 3
	Backtrace:
	
		
	
		
	
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/themes/geocities/views/view/download.php
			Line: 3
			Function: header			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
			Line: 173
			Function: include			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/core/MY_Loader.php
			Line: 43
			Function: _ci_load			
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/application/controllers/Main.php
			Line: 625
			Function: view			
		
	
		
	
		
			
			File: /home/httpd/vhosts/scratchbook.ch/geopaste.scratchbook.ch/index.php
			Line: 315
			Function: require_once			
		
	
 ' Gambas module file
Private spd_i2c_eeprom_dir As String[] = ["/sys/bus/i2c/drivers/eeprom/",
  "/sys/bus/i2c/drivers/ee1004/",
  "/sys/bus/i2c/drivers/at24/",
  "/home/michal/Dokumenty/SPD/"]
Private spd_i2c_eeprom_files As New String[] 
Private eeprom_file_name As String = "eeprom"
Private Enum UNKNOWN = 0,
  DIRECT_RAMBUS = 1,
  RAMBUS = 2,
  FPM_DRAM = 3,
  EDO = 4,
  PIPELINED_NIBBLE = 5,
  SDR_SDRAM = 6,
  MULTIPLEXED_ROM = 7,
  DDR_SGRAM = 8,
  DDR_SDRAM = 9,
  DDR2_SDRAM = 10,
  DDR3_SDRAM = 11,
  DDR4_SDRAM = 12,
  N_RAM_TYPES = 13
Private ram_types As String[] = ["Unknown", "Direct Rambus", 
  "Rambus", "FPM DRAM", "EDO", 
  "Pipelined Nibble", "SDR SDRAM", 
  "Multiplexed ROM", "DDR SGRAM", 
  "DDR SDRAM", "DDR2 SDRAM", 
  "DDR3 SDRAM", "DDR4 SDRAM"]
Public spd_size As New Long[]
Public ram_type_str As New String[]
Public ram_type_int As New Integer[]
Public spd_revision As New String[]
Public part_number As New String[]
Public module_type As New String[]
Public module_speed As New String[]
Public module_size As New String[]
Public voltage As New String[]
Public module_manufacturer As New String[]
Public module_dram_manufacturer As New String[]
Public module_manufacture_date As New String[]
Public eeprom As New Byte[512]
Private Function read_spd(file_path As String)
  Dim eeprom_file As File
  eeprom_file = Open file_path For Read
  eeprom.Read(eeprom_file, 0, Lof(eeprom_file))
  eeprom_file.Close
End
Private Function calculate_spd_size(file_path As String) As Long
  If Exist(file_path) Then
    Return Stat(file_path).Size
  Else
    Return Null
  Endif
End
Private Function find_spd_eeprom_file()
  Dim eeprom_file As File
  Dim eeprom_byte As New Byte[512]
  Dim i As Integer
  
  For i = 0 To spd_i2c_eeprom_dir.Max
    If Exist(spd_i2c_eeprom_dir[i]) Then
      For Each element As String In Dir(spd_i2c_eeprom_dir[i], "*-****")
        If Exist(spd_i2c_eeprom_dir[i] &/ element &/ eeprom_file_name) Then
          eeprom_file = Open (spd_i2c_eeprom_dir[i] &/ element &/ eeprom_file_name) For Read
          eeprom_byte.Read(eeprom_file, 0, Lof(eeprom_file))
          If eeprom_byte[0] > 0 Then
            spd_i2c_eeprom_files.Add(spd_i2c_eeprom_dir[i] &/ element &/ eeprom_file_name)
          Endif
          eeprom_file.Close
        Endif
      Next
    Endif
  Next
End
Public Sub Main()
  Dim i As Integer
  Dim eeprom_file As File
  Dim eeprom_byte As New Byte[]
  find_spd_eeprom_file()
  
  For Each Variable As String In spd_i2c_eeprom_files
    spd_size.Add(calculate_spd_size(Variable))
  Next
  
  For i = 0 To spd_i2c_eeprom_files.Max
    read_spd(spd_i2c_eeprom_files[i])
    ram_type_str.Add(ram_types[decode_ram_type(eeprom)])
    ram_type_int.Add(decode_ram_type(eeprom))
    
    Select ram_type_int[i]
      Case SDR_SDRAM
      Case DDR_SDRAM
      Case DDR2_SDRAM
      Case DDR3_SDRAM
        spd_revision.Add(decode_ddr3_spd_revision(eeprom))
        part_number.Add(decode_ddr3_part_number(eeprom))
        module_type.Add(decode_ddr3_module_type(eeprom))
        module_speed.Add(decode_ddr3_module_speed(eeprom))
        module_size.Add(decode_ddr3_module_size(eeprom))
        voltage.Add(decode_ddr3_voltage(eeprom))
        module_manufacturer.Add(decode_ddr3_module_manufacturer(eeprom))
        module_dram_manufacturer.Add(decode_ddr3_module_dram_manufacturer(eeprom))
        module_manufacture_date.Add(decode_ddr3_module_date(eeprom[120], eeprom[121]))
        'Print "Manufacturer:" & Hex(eeprom[117] And &h7F) & " " & Hex(eeprom[118])
        'Print CMemVendors.MemVendors[CString(Hex(eeprom[117] And &h7F))][LCase(Hex(eeprom[118]))]
        
        'decode_ddr34_manufacturer(eeprom[117], eeprom[118])
      Case DDR4_SDRAM
        part_number.Add(decode_ddr4_part_number(eeprom))
        module_type.Add(decode_ddr4_module_type(eeprom))
        module_speed.Add(decode_ddr4_module_speed(eeprom))
        module_size.Add(decode_ddr4_module_size(eeprom))
        module_manufacturer.Add(decode_ddr4_module_manufacturer(eeprom))
        module_dram_manufacturer.Add(decode_ddr4_module_dram_manufacturer(eeprom))
        module_manufacture_date.Add(decode_ddr4_module_date(eeprom, spd_size[i], eeprom[323], eeprom[324]))
    End Select
  Next
  Print 
  For i = 0 To spd_size.max
    Try Print ram_type_str[i];;
    
    Try Print module_manufacturer[i];;
    Try Print module_dram_manufacturer[i]
    Try Print "Manufacturing Date: "; module_manufacture_date[i]; " | ";
    Try Print part_number[i]
    Try Print module_type[i];;
    
    Try Print module_speed[i]
    Try Print module_size[i] & " MB";;
    Try Print voltage[i];;
    Try Print spd_size[i];;
    
    Try Print ram_type_int[i];;
    Try Print spd_revision[i]
    Print "\n"
    
  Next
  
End
Private Function decode_ddr3_spd_revision(bytes As Byte[]) As String
  Return Mid(Hex(bytes[1]), 1, 1) & "." & Mid(Hex(bytes[1]), 2, 1)
End
Private Function decode_ddr3_part_number(bytes As Byte[], Optional partnumber As String) As String
  Dim i As Integer
  For i = 128 To 145
    partnumber &= Chr(bytes[i])
  Next
  Return partnumber
End
Private Function decode_ddr4_part_number(bytes As Byte[], Optional partnumber As String) As String
  Dim i As Integer
  For i = 329 To 348
    partnumber &= Chr(bytes[i])
  Next
  Return partnumber
End
Private Function decode_ddr3_module_type(bytes As Byte[]) As String
  Dim type As String
  Select bytes[3]
    Case 01
      type = "RDIMM (Registered Long DIMM)"
    Case 02
      type = "UDIMM (Unbuffered Long DIMM)"
    Case 03
      type = "SODIMM (Small Outline DIMM)"
    Default
      type = Null
  End Select
  Return type
End
Private Function decode_ddr4_module_type(bytes As Byte[]) As String
  Dim type As String = "Unknown" ''Default Unknown if no detect
  Select Hex(bytes[3], 2)
    Case "01"
      type = "RDIMM (Registered DIMM)"
    Case "02"
      type = "UDIMM (Unbuffered DIMM)"
    Case "03"
      type = "SODIMM (Small Outline Unbuffered DIMM)"
    Case "04"
      type = "LRDIMM (Load-Reduced DIMM)"
    Case "05"
      type = "Mini-RDIMM (Mini Registered DIMM)"
    Case "06"
      type = "Mini-UDIMM (Mini Unbuffered DIMM)"
    Case "08"
      type = "72b-SO-RDIMM (Small Outline Registered DIMM, 72-bit data bus)"
    Case "09"
      type = "72b-SO-UDIMM (Small Outline Unbuffered DIMM, 72-bit data bus)"
    Case "0c"
      type = "16b-SO-UDIMM (Small Outline Unbuffered DIMM, 16-bit data bus)"
    Case "0d"
      type = "32b-SO-UDIMM (Small Outline Unbuffered DIMM, 32-bit data bus)"
    Default
      type = Null
  End Select
  Return type
End
Private Function decode_ddr3_module_speed(bytes As Byte[]) As String
  ' Dim ctime As Float
  ' Dim ddrclk As Float
  ' Dim tbits, pcclk As Integer
  ' Dim mtb As Float = 0.125
  ' 
  ' If (bytes[10] == 1 And bytes[11] == 8) Then mtb = 0.125
  ' If (bytes[10] == 1 And bytes[11] == 15) Then mtb = 0.0625
  ' ctime = mtb * bytes[12]
  ' ddrclk = 2 * (1000 / ctime)
  ' 
  ' tbits = 64
  ' Select bytes[8]
  '   Case 1
  '     tbits = 16
  '   Case 4
  '     tbits = 32
  '   Case 3
  '   Case 0
  '     tbits = 64
  ' End Select
  ' 
  ' pcclk = ddrclk * (tbits / 8)
  ' pcclk -= pcclk % 100
  ' 
  ' Return Subst("DDR3-&1Mhz PC3-&2", CInt(ddrclk), pcclk)
  Dim divisor As Integer = bytes[10]
  Dim dividend As Integer = bytes[11]
  Dim ratio As Integer = bytes[12]
  If dividend = 0 And divisor = 0 And ratio = 0 Then
    Return "DDR3-Unknown Mhz"
  Else
    Return Subst("DDR3-&1Mhz", ((2000 * dividend) / (divisor * ratio)))
  Endif
End
Private Function decode_ddr4_module_speed(bytes As Byte[]) As String
  Dim mincycle As Integer = bytes[18]
  Dim fineadjust As Integer = Bytes[125]
  Dim frequency As Integer
  frequency = (2000000 / (mincycle * 125 + fineadjust))
  Return Subst("DDR4-&1Mhz", frequency)
End
Private Function decode_ddr3_module_size(bytes As Byte[]) As String
  Dim size As Integer
  ' Dim sdr_capacity As Integer = Lsl(256, Hex(bytes[4]) And &hF)
  ' Dim sdr_width As Integer = Lsl(4, Hex(bytes[7]) And &h7)
  ' Dim bus_width As Integer = Lsl(8, Hex(bytes[8]) And &h7)
  ' Dim ranks As Integer = 1 + Lsr(3, Hex(bytes[7]) And &h7)
  
  ' Print "sdr_capacity = " & Lsl(256, Bytes[4])
  ' Print "sdr_width = " & Lsl(4, bytes[7])
  ' Print "bus_width = " & Lsl(8, bytes[8])
  ' Print "ranks = " & (Lsr(3, bytes[7]) + 1)
  
  ' size = sdr_capacity / 8 * bus_width / sdr_width * ranks
  
  size = ((Hex(bytes[4]) And &h0f) + 28) + ((Hex(bytes[8]) And &h7) + 3)
  size -= (Hex(bytes[7]) And &h7) + 25
  size = (Lsl(1, size)) * (Lsr(3, bytes[7] And &h1f) + 1)
  Return Subst("Module size: &1", size / 1024)
End
Private Function decode_ddr4_module_size(bytes As Byte[]) As String
  Dim sdram_width As Integer
  Dim ranks As Integer
  Dim signal_loading As Integer
  Dim die_count As Integer
  Dim cap As Integer
  
  sdram_width = 4 * CInt(2 ^ (bytes[12] And &h07))
  ranks = ((bytes[12] \ CInt(2 ^ 3)) And &h07) + 1
  signal_loading = (bytes[6] And &h03)
  die_count = ((bytes[12] \ CInt(2 ^ 4)) And &h07) + 1
  cap = (256 * CInt(2 ^ (bytes[4] And &h0f))) / 8
  cap *= (8 * CInt(2 ^ (bytes[13] And &h07))) / sdram_width
  cap *= ranks
  If signal_loading = &h02 Then
    cap *= die_count 
  Endif
  ' Print "sdram_width: " & sdram_width
  ' Print "ranks: " & ranks
  ' Print "signal_loading: " & signal_loading
  ' Print "die_count: " & die_count
  ' Print "cap: " & cap
  
  Return Subst("&1", cap)
  
End
' # Size computation
'   my $sdram_width = 4 << ($bytes->[12] & 0x07);
'   my $ranks = (($bytes->[12] >> 3) & 0x07) + 1;
'   my $signal_loading = $bytes->[6] & 0x03;
'   my $die_count = (($bytes->[6] >> 4) & 0x07) + 1;
'   my $cap = (256 << ($bytes->[4] & 0x0f)) / 8;
'   $cap *= (8 << ($bytes->[13] & 0x07)) / $sdram_width;
'   $cap *= $ranks;
'   $cap *= $die_count if $signal_loading == 0x02;    # 3DS
'   printl("Size", $cap . " MB");
Private Function decode_ddr3_voltage(bytes As Byte[]) As String
  
  Return If(bytes[6] = 4, "1.25V ", "") & If(bytes[6] = 2, "1.35V ", "") & If(bytes[6] = 1, "", "1.5V")
  
End
Private Function decode_ddr3_module_manufacturer(bytes As Byte[]) As String
  
  Return decode_ddr34_manufacturer(bytes[117], bytes[118])
  
End
Private Function decode_ddr3_module_dram_manufacturer(bytes As Byte[]) As String
  Return decode_ddr34_manufacturer(bytes[148], bytes[149])
  
End
Private Function decode_ddr4_module_manufacturer(bytes As Byte[]) As String
  Return decode_ddr34_manufacturer(bytes[320], bytes[321])
  
End
Private Function decode_ddr4_module_dram_manufacturer(bytes As Byte[]) As String
  Return decode_ddr34_manufacturer(bytes[350], bytes[351])
  
End
Private Function decode_ddr34_manufacturer(count As Byte, code As Byte) As String
  Dim Manufacturer As String
  Dim bank As String
  Dim index As String
  bank = Hex(count And &h7f, 1)
  index = Hex(code And &h7f, 2)
  Manufacturer = CMemVendors.MemVendors[bank][index]
  
  If Manufacturer = Null Then
    index = LCase(index)
    Manufacturer = CMemVendors.MemVendors[bank][index]
  Endif
  
  If Manufacturer = Null Then
    index = LCase(Hex(code))
    Manufacturer = CMemVendors.MemVendors[bank][index]
  Endif
  Return Manufacturer
End
Private Function decode_ddr3_module_date(syear As Byte, sweek As Byte) As String
  'Print syear; " "; sweek
  syear = Hex(syear)
  sweek = Hex(sweek)
  'Print syear; " "; sweek
  If (syear And &hf0) <= &h90 Or (syear And &h0f) <= &h09 Or (sweek And &hf0) <= &h90 Or (sweek And &h0f) <= &h09 Then
    
    Return Subst("&1&2 W&3", IIf(syear >= &h80, 19, 20), syear, sweek)
    
  Else If (syear <= 99 Or sweek >= 1 Or sweek <= 53) Then
    
    Return Subst("&1&2 W&3", IIf(syear >= 80, 19, 20), syear, sweek)
  
  Else
  
    Return Subst("&1 W&2", syear, sweek)
    
  Endif
  Return "UNKNOWN"
End
Private Function decode_ddr4_module_date(Optional bytes As Byte[], Optional spd_size As Long, syear As Byte, sweek As Byte) As String
  'Print "DDR4 Byte"; syear; " "; sweek
  syear = Hex(syear)
  sweek = Hex(sweek)
  'Print "DDR4 Hex"; syear; " "; sweek
  If (spd_size < 324) Then
    Return "Unknown"
  Endif
  If bytes[323] = &h0 Or bytes[323] = &hff And If bytes[324] = &h0 Or bytes[324] = &hff Then
    Return "Unknown"
  Endif
  Return Subst("&1&2 W&3", IIf(syear >= 80, 19, 20), syear, sweek)
  
End
Private Function decode_ram_type(bytes As Byte[]) As Integer
  If bytes[0] < 4 Then
    Select bytes[2]
      Case 1
        Return DIRECT_RAMBUS
      Case 17
        Return RAMBUS
    End Select
  Else
    Select bytes[2]
      Case 1 
        Return FPM_DRAM
      Case 2 
        Return EDO
      Case 3
        Return PIPELINED_NIBBLE
      Case 4
        Return SDR_SDRAM
      Case 5
        Return MULTIPLEXED_ROM
      Case 6 
        Return DDR_SGRAM
      Case 7
        Return DDR_SDRAM
      Case 8
        Return DDR2_SDRAM
      Case 11
        Return DDR3_SDRAM
      Case 12
        Return DDR4_SDRAM
    End Select
    Return UNKNOWN
  Endif
End