Cita:
Iniciado por lexus
aguien tiene una idea?

lexus... mira no estoy seguro si entendi bien el codigo... pero hay te va
requiere convertir de base64_decode, hay que buscar un similar para ASP, asi que esta creo que te ayudara
Código PHP:
' Decodes a base-64 encoded string (BSTR type).
' 1999 - 2004 Antonin Foller, http://www.motobit.com
' 1.01 - solves problem with Access And 'Compare Database' (InStr)
Function Base64Decode(ByVal base64String)
Const Base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Dim dataLength, sOut, groupBegin
'remove white spaces, If any
base64String = Replace(base64String, vbCrLf, "")
base64String = Replace(base64String, vbTab, "")
base64String = Replace(base64String, " ", "")
'The source must consists from groups with Len of 4 chars
dataLength = Len(base64String)
If dataLength Mod 4 <> 0 Then
Err.Raise 1, "Base64Decode", "Bad Base64 string."
Exit Function
End If
' Now decode each group:
For groupBegin = 1 To dataLength Step 4
Dim numDataBytes, CharCounter, thisChar, thisData, nGroup, pOut
' Each data group encodes up To 3 actual bytes.
numDataBytes = 3
nGroup = 0
For CharCounter = 0 To 3
' Convert each character into 6 bits of data, And add it To
' an integer For temporary storage. If a character is a '=', there
' is one fewer data byte. (There can only be a maximum of 2 '=' In
' the whole string.)
thisChar = Mid(base64String, groupBegin + CharCounter, 1)
If thisChar = "=" Then
numDataBytes = numDataBytes - 1
thisData = 0
Else
thisData = InStr(1, Base64, thisChar, vbBinaryCompare) - 1
End If
If thisData = -1 Then
Err.Raise 2, "Base64Decode", "Bad character In Base64 string."
Exit Function
End If
nGroup = 64 * nGroup + thisData
Next
'Hex splits the long To 6 groups with 4 bits
nGroup = Hex(nGroup)
'Add leading zeros
nGroup = String(6 - Len(nGroup), "0") & nGroup
'Convert the 3 byte hex integer (6 chars) To 3 characters
pOut = Chr(CByte("&H" & Mid(nGroup, 1, 2))) + _
Chr(CByte("&H" & Mid(nGroup, 3, 2))) + _
Chr(CByte("&H" & Mid(nGroup, 5, 2)))
add numDataBytes characters To out string
sOut = sOut & Left(pOut, numDataBytes)
Next
Base64Decode = sOut
End Function
despues, hay una funcion "unlink" que borra los archivo, por lo tanto nosotros en ASP, debes crear una funcion con FSO para realizar esto
Código PHP:
function Eliminar(archivo)
exito=false
Dim objFSO
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
'borro file
If (objFSO.FileExists(archivo))=true Then
' Response.Write("File "&deli&" exists.")
objFSO.DeleteFile archivo , False
exito=true
Else
Response.Write("File "&deli&" does not exist.")
End If
response.Flush()
set objFSO = nothing
eliminar = exito
end function
otra funcion que ya viene integrada en PHP "unlink" elimina cualquier etiqueta HTML, y nuestro gran amigo Tammander, proporciono su funcion en post pasados, asi que nos sera muy util esta ves ( gracias Tamm

)
Código PHP:
Function SafeHTML(ByVal pStrHTML)
Dim lObjRegExp
If null
If VarType(pStrHTML) = 1 Then Exit Function
If pStrHTML = "" Then Exit Function
Set lObjRegExp = New RegExp
lObjRegExp.Global = True
lObjRegExp.IgnoreCase = True
lObjRegExp.Pattern = "<(/)?SCRIPT|META|STYLE([^>]*)>"
pStrHTML = lObjRegExp.Replace(pStrHTML, "")
lObjRegExp.Pattern = "<(/)?(HTML|HEAD|BODY)([^>]*)>"
pStrHTML = lObjRegExp.Replace(pStrHTML, "")
lObjRegExp.Pattern = "<(/)?(LINK|IFRAME|FRAMESET|FRAME|APPLET|OBJECT)([^>]*)>"
pStrHTML = lObjRegExp.Replace(pStrHTML, "")
lObjRegExp.Pattern = "<(/)?(BUTTON|FORM|FIELDSET|INPUT|SELECT|OPTION)([^>]*)>"
pStrHTML = lObjRegExp.Replace(pStrHTML, "")
lObjRegExp.Pattern = "(<A[^>]+href\s?=\s?""?javascript:)[^""]*(""[^>]+>)"
pStrHTML = lObjRegExp.Replace(pStrHTML, "")
lObjRegExp.Pattern = "(<IMG[^>]+src\s?=\s?""?javascript:)[^""]*(""[^>]+>)"
pStrHTML = lObjRegExp.Replace(pStrHTML, "")
lObjRegExp.Pattern = "<([^>]*) on[^=\s]+\s?=\s?([^>]*)>"
pStrHTML = lObjRegExp.Replace(pStrHTML, "")
Set lObjRegExp = Nothing
SafeHTML = pStrHTML
End Function
y pues el resto es interpretacion, asi que espero haberte ayudar, comente las lineas PHP, para que mas o menos se pudiera ver que linea hacia que
Código PHP:
Const ForReading = 1, ForWriting = 2
Dim fso, f
'if ($_REQUEST["bindata"] === NULL) {
if isnull(request("bindata")) then
echo "missing parameter.";}
response.Write "Parametros nulos"
'else {
else
' $img_data = base64_decode($_REQUEST["bindata"]);
img_data = Base64Decode(request("bindata"))
' $name = $_REQUEST["name"] === NULL ? "anonymous\n" : $_REQUEST["name"] ."\n";
if (isnull(request("name")) or (request("name")="anonymous")) then name_data = request("name") end if
' $name = strip_tags($name);
name_data = SafeHTML(name_data)
' $comment = strip_tags($_REQUEST["comment"]) . "\n";
comment = SafeHTML(request("comment"))
' $img_size = strlen($img_data);
img_size = len(name_data)
' if ($img_size < 10000) {
if (img_size < 10000)
' $img_filename = "data/snapshot.jpg";
carpeta = server.MapPath("./data/")
img_filename = "snapshot.jpg"
' $comment_filename = "data/comment.txt";
comment_filename = "comment.txt"
' unlink($img_filename);
eliminar(carpeta&"\"&img_filename)
' unlink($comment_filename);
eliminar(carpeta&"\"&comment_filename)
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(carpeta & "" & img_filename, ForWriting, True)
if Err=0 then
f.Write img_data
response.Write img_size & " bytes actualizados"
else
response.Write "can't open file"
end if
f.close
fso.Close
set f=nothing
set fso=nothing
' img_file = fopen($img_filename, "w") or
' fwrite($img_file, $img_data);
' fclose($img_file);
' echo "$img_size bytes uploaded.";
' // write comments
' var_dump($comment);
' $comment_lines = explode("\r", $comment);
comment_lines = split("<br>", comment)
' var_dump($comment_lines);
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(carpeta & "\" & comment_filename, ForWriting, True)
if Err=0 then
for each item in comment_lines
f.Write item & "<br>"
' response.Write img_size & " bytes actualizados"
next
else
response.Write "can't open file"
end if
f.close
fso.Close
set f=nothing
set fso=nothing
' $comment_file = fopen($comment_filename, "w");
' fwrite($comment_file, $name);
' foreach ($comment_lines as $line)
' {
' fwrite($comment_file, $line . "\n");
' }
' //fwrite($comment_file, $comment);
' fclose($comment_file);
' }
' else {
else
echo "image too big.";
response.Write "imagen demasiado grande."
' }
end if
' }
end if
'//var_dump($_REQUEST);
'?>
%>
y ahora que hago, se esta pasando el efecto de la espuma, no sobro???