IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

conversion code asp vers php 5


Sujet :

Langage PHP

  1. #1
    Membre habitué
    Homme Profil pro
    Inscrit en
    Mars 2009
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Mars 2009
    Messages : 114
    Points : 185
    Points
    185
    Par défaut conversion code asp vers php 5
    j'ai du mal à convertir une fonction asp en php 5 !
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    Private Sub Class_Initialize()
     
    		Dim lnBytes				' Bytes received from the client
    		Dim lnByteCount			' Number of bytes received
    		Dim lnStartPosition		' Position at which content begins
    		Dim lnEndPosition		' Position at which content ends
     
    		Dim loDic				' Contains properties of each
    								' specific field
    								' Local dictionary object(s) 
    								' to be appended to class-scope
    								' dictioary object.
     
    		Dim lnBoundaryBytes		' Bytes contained within the current boundary
    		Dim lnBoundaryStart		' Position at wich the current boundary begins
    								' within the lnBytes binary data.
    		Dim lnBoundaryEnd		' Position at wich the current boundary ends
    								' within the lnBytes binary data.
    		Dim lnDispositionPosition
     
    		Dim lsFieldName			' Name of the current field being parsed from
    								' Binary Data
    		Dim lsFileName			' Name of the file within the current boundary
    		Dim lnFileNamePosition	' Location of file name within current boundary
    		Dim loField				' clsField Object
    		Dim lsValue				' Value of the current field
    		Dim lsContentType		' ContentType of the binary file (MIME Type)
     
    		' Initialize Fields
    		nFieldCount = 0
    		ReDim oFields(-1)
     
    		' Read the bytes (binary data) into memory	
    		lnByteCount = Request.TotalBytes
    		lnBytes = Request.BinaryRead(lnByteCount)
     
    		'Get the lnBoundaryBytes
    		lnStartPosition = 1
    		lnEndPosition = InstrB(lnStartPosition, lnBytes, CStrB(vbCr))
     
    		If lnEndPosition >= lnStartPosition Then
    			lnBoundaryBytes = MidB(lnBytes, lnStartPosition, lnEndPosition - lnStartPosition)
    		End If
     
    		lnBoundaryStart = InstrB(1, lnBytes, lnBoundaryBytes)
     
     
    		' Loop until the BoundaryBytes begin with "--"
    		Do Until (lnBoundaryStart = InstrB(lnBytes, lnBoundaryBytes & CStrB("--")))
     
    			' All data within this boundary is stored within a local dictionary
    			' to be appended to the class-scope dictionary.
     
    			ReDim Preserve oFields(nFieldCount)
    			nFieldCount = nFieldCount + 1
     
    			Set loField = New clsField
     
    			lnDispositionPosition = InstrB(lnBoundaryStart, lnBytes, CStrB("Content-Disposition"))
     
    			' Get an object name
    			lnStartPosition = InstrB(lnDispositionPosition, lnBytes, CStrB("name=")) + 6
    			lnEndPosition = InstrB(lnStartPosition, lnBytes, CStrB(""""))
    			lsFieldName = CStrU(MidB(lnBytes, lnStartPosition, lnEndPosition - lnStartPosition))
    			loField.FieldName = lsFieldName
     
    			' Get the location fo the file name.
    			lnFileNamePosition = InstrB(lnBoundaryStart, lnBytes, CStrB("filename="))
    			lnBoundaryEnd = InstrB(lnEndPosition, lnBytes, lnBoundaryBytes)
     
    			'Test if object is a file
    			If Not lnFileNamePosition = 0 And lnFileNamePosition < lnBoundaryEnd Then
     
    				' Parse Filename
    				lnStartPosition = lnFileNamePosition + 10
    				lnEndPosition =  InstrB(lnStartPosition, lnBytes, CStrB(""""))
    				lsFileName = CStrU(MidB(lnBytes,lnStartPosition,lnEndPosition-lnStartPosition))
    				loField.FileName = lsFileName				
     
    				' Parse Content-Type
    				lnStartPosition = InstrB(lnEndPosition,lnBytes,CStrB("Content-Type:")) + 14
    				lnEndPosition = InstrB(lnStartPosition,lnBytes,CStrB(vbCr))
    				lsContentType = CStrU(MidB(lnBytes,lnStartPosition,lnEndPosition-lnStartPosition))
    				loField.ContentType = lsContentType
     
    				' Parse Content
    				lnStartPosition = lnEndPosition + 4
    				lnEndPosition = InstrB(lnStartPosition,lnBytes,lnBoundaryBytes)-2
    				lsValue = MidB(lnBytes,lnStartPosition,lnEndPosition-lnStartPosition)
    				loField.BinaryData = lsValue & CStrB(vbNull)
    				loField.Length = LenB(lsValue)
    			Else
     
    				' Parse Content
    				lnStartPosition = InstrB(lnDispositionPosition, lnBytes, CStrB(vbCr)) + 4
    				lnEndPosition = InstrB(lnStartPosition, lnBytes, lnBoundaryBytes) - 2
    				lsValue = CStrU(MidB(lnBytes,lnStartPosition,lnEndPosition-lnStartPosition))
    				loField.Value = lsValue
    				loField.Length = Len(lsValue)
    			End If
     
    			Set oFields(UBound(oFields)) = loField
     
    			'Loop to next object
    			lnBoundaryStart = InstrB(lnBoundaryStart + LenB(lnBoundaryBytes), lnBytes, lnBoundaryBytes)
     
    			Set loField = Nothing
     
    		Loop
     
    	End Sub

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Quel point te pose problème ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Membre habitué
    Homme Profil pro
    Inscrit en
    Mars 2009
    Messages
    114
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Mars 2009
    Messages : 114
    Points : 185
    Points
    185
    Par défaut
    Les fonctions suivantes :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    BinaryRead
    InstrB
    CStrb

Discussions similaires

  1. conversion fonction asp vers php 5
    Par baderahmed dans le forum ASP
    Réponses: 0
    Dernier message: 18/01/2011, 16h32
  2. conversion asp vers php
    Par fralie dans le forum Langage
    Réponses: 1
    Dernier message: 28/03/2008, 10h12
  3. Migrer un site en ASP vers PHP ou ASP.Net
    Par fredouille31 dans le forum ASP
    Réponses: 4
    Dernier message: 23/08/2007, 21h17
  4. Converstion Caddy ASP vers PHP
    Par delavega dans le forum Langage
    Réponses: 1
    Dernier message: 25/08/2006, 09h59
  5. Passage de ASP vers PHP
    Par FoxLeRenard dans le forum Langage
    Réponses: 2
    Dernier message: 26/04/2006, 17h15

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo