Jump to content
Sign in to follow this  
dev

Php To Asp

Recommended Posts

Sir,Please help me to convert this php code to asp<?php$result = array(); $result['time'] = date('r');$result['addr'] = substr_replace(gethostbyaddr($_SERVER['REMOTE_ADDR']), '******', 0, 6);$result['agent'] = $_SERVER['HTTP_USER_AGENT']; if (count($_GET)) { $result['get'] = $_GET;}if (count($_POST)) { $result['post'] = $_POST;}if (count($_FILES)) { $result['files'] = $_FILES;} if (file_exists('script.log') && filesize('script.log') > 102400) { unlink('script.log');} $log = @fopen('script.log', 'a');if ($log) { fputs($log, print_r($result, true) . "\n---\n"); fclose($log);} $error = false; if (!isset($_FILES['Filedata']) || !is_uploaded_file($_FILES['Filedata']['tmp_name'])) { $error = 'Invalid Upload';} if ($error) { $return = array( 'status' => '0', 'error' => $error ); } else { $return = array( 'status' => '1', 'name' => $_FILES['Filedata']['name'] ); // Our processing, we get a hash value from the file $return['hash'] = md5_file($_FILES['Filedata']['tmp_name']); // ... and if available, we get image data $info = @getimagesize($_FILES['Filedata']['tmp_name']); if ($info) { $return['width'] = $info[0]; $return['height'] = $info[1]; $return['mime'] = $info['mime']; } } if (isset($_REQUEST['response']) && $_REQUEST['response'] == 'xml') { // header('Content-type: text/xml'); // Really dirty, use DOM and CDATA section! echo '<response>'; foreach ($return as $key => $value) { echo "<$key><![CDATA[$value]]></$key>"; } echo '</response>';} else { // header('Content-type: application/json'); echo json_encode($return);}?>

Share this post


Link to post
Share on other sites

It might help if you:

  1. Indicate the purpose of this code and/or where you got it so its function can be identified (functional translations are more likely than a line-by-line translation).
  2. If you are multi-lingual (code in both PHP and ASP) then provide not only the ASP code (like you did), but also provide your attempted PHP translation that doesn't work (and indicate where you are having problems).
  3. You might post this problem in the ASP forum, since many here in PHP are not ASP coders and you may get more response in the ASP forum (if someone there is multi-lingual).

I asked for some help translating ASP code (which I don't understand at all) into PHP which was actually direct from the w3schools tutorial itself, and only one valiant forum member was willing to try to provide a translation of the coding I sent in, and it was as long and big as your code (and even though I thought since it was w3schools code that I would get more than one responder, one was all I got). Please understand that you're expecting a lot of work from someone to do this for you (as I was), so I suggest you show your work in translating it yourself if you understand both languages, as you'll be more likely to get a response than expecting someone to do all the work for you. In my case, I couldn't help provide both sides of the ASP-to-PHP codes since I don't understand the ASP language (period), but that's also why I got little response (but what I did get was very helpful, though not complete according to the person who provided it). If I could help I would, but I'm not multi-lingual in ASP and PHP. I wish you the best!

Share this post


Link to post
Share on other sites

That script uses file uploads in PHP, ASP classic doesn't have built-in support for uploading files, at least not in a way usable by a human. You need to use a file upload component that needs to be installed on the server, if you're hosting your ASP files on someone else's server ask them if they have a file upload component for ASP installed.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...