Permalänk

ASP till PHP

hej,
Jag har en liten kod snutt skriven i ASP/VBScript som jag skulle vilja ha i PHP. Finns det nån program som konverterar automatiskt mellan de formaten, eller är det bara skitsnack? Om det inte finns, skulle nån vänlig själ ägna nån minut åt att fixa koden i php? Tack på förhand.

/TranceMaster

Permalänk
Medlem

Så vitt jag vet finns det inget program som helt konverterar koden, möjligtvis lite response.write till echo.
Det var ett tag sen jag höll på med ASP, men om du postar koden så kan jag försöka.

Permalänk

ASP/VBScript
(requires MSXML)

<%@LANGUAGE="VBScript"%>
<%

' syntax : conob.asp?code=username:password:secret:type
' username = an integer
' password = a string of non capital letters
' secret = a string of letter both capital and non capital
' type = 'add', or 'remove'

'SHORT INSTALLATION GUIDE
'Enter the URL of your conob.asp script in the settings(URL) in your account at www.conob.com
'Change the value of the variable, "secret", below
'Make the changes needed to add/remove information from your database

Dim username, password, mysecret, type, tariff_USD, payout_USD
Dim code
Dim myArray() As String

'**********************************
Dim secret As String = "Enter the Account secret here!"
' This is the secret given to you by CONOB.
'**********************************

' assign posted variable to a local variable
code = Request.Form("code")

' split the code value into local variables
myArray() = Split(code,":")
username = myArray(0)
password = myArray(1)
mysecret = myArray(2)
type = myArray(3)

'Check if the secret is correct
if mySecret = secret then
if type = "add" then
'Insert the username/password into the database
'Write to log file
end if

if type = "remove" then
'Find the username/password in the database and delete that post from the database.
'Write to log file
end if
else
'Write to log file that the secret was incorrect. This should be investigated!!
end if

%>

Jo jag förstod nästan att det inte går att konvertera automatiskt.
Men här har du koden, hoppas det går bra.....tack för hjälpen.

/TranceMaster

Permalänk
Medlem
Permalänk
Medlem

Detta borde fixa biffen, orkade inte skriva in alla kommentarer, men här har du det i alla fall.

<?php // Syntax: conob.asp?code=username:password:secret:type // username = an integer // password = a string of non capital // type = 'add' or 'remove' // SHORT INSTALLATION GUIDE // Enter the URL of your conob.asp script in the settings(URL) in your account at www.conob.com // Change the value of the variable, "secret", below // Make the changes needed to add/remove information from your database // assign posted variable to a local variable $code = $_POST['code']; // split the code value into a local variable $myarray = explode(":", $code); $username = $myarray[0]; $password = $myarray[1]; $mysecret = $myarray[2]; $type = $myarray[3]; // Check if the secret is correct if ($mysecret == "secret") { // Find the username/password in the database and delete the post from the database // Write a logfile } else { // Write a logfile that the secret was incorrect. This should be investigated! } ?>

Egentligen bör man köra htmlspecialchars() eller liknande på POST-data, tex så här:

$code = htmlspecialchars($_POST['code']);

Det förhindrar att användare förstör genom att mata in HTML- eller PHP-kod.

Permalänk

Jätte tack, funkar säkert bra.
Ska testa senare när jag kommer hem.

även om jag inte förstår var du fick "tongue.gif" ifrån :). och vad är assword

/Trancemaster

Permalänk
Hedersmedlem

Fast om syntaxen är exempelvis hej.asp(php)?code=
så kan man ju inte använda Request.Form("code")/$_POST['code], det är ju Request.QueryString("code")/$_GET['code'] man måste använda...

Visa signatur

Vim
Kinesis Classic Contoured (svart), Svorak (A5)
Medlem i signaturgruppen Vimzealoter.

Permalänk

Fan jag måste lära mig programmering, ska ta det under sommaren. Jävla plugg :D, man har inte tid med något annat.

/TranceMaster

Permalänk
Medlem
Citat:

Ursprungligen inskrivet av m0REc
Fast om syntaxen är exempelvis hej.asp(php)?code=
så kan man ju inte använda Request.Form("code")/$_POST['code], det är ju Request.QueryString("code")/$_GET['code'] man måste använda...

Ah, självklart, att jag inte såg det.
Översatte bara koden, tänkte inte alls på vad den gjorde