Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 9th, 2004, 11:09 AM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default php to asp

Hello all,
This is my first time here.
Not sure if this thread should be posted in php but since my issue is with understanding the equivalence of this code in asp, I decided to try here.
I am an asp programmer but for the past week, I have been mired in trying to rewrite a php code in asp.
I have managed to rewrite about 90% of the code but got stuck with the portion below:

vch = curl_init("http/ms4.0/mapserv?map=/web/wms/ms/terrain/mapserv.map&mode=map&layers=dem&map_imagetype=AAIG rid&mapsize=vmapwidth+vmapheight&mapext=".str_repl ace(" ","+",vmapext));
vfp = fopen(vinputfile,"w");
curl_setopt(vch,CURLOPT_FILE,vfp);
curl_setopt(vch,CURLOPT_HEADRER,0);
curl_setopt(vch,CURLOPT_VERBOSE,0);
curl_exec(vch);
curl_close(vch);
fclose(vfp);

I just can't seem to make any sense it.

For instance, I have no idea what the equivalence of curl_init, curl_setopt, curl_exec, curl_close, fopen, curlopt_file,curlopt_header and curl_verbose are in asp.

I would greatly appreciate if anyone here knows both asp and php and is willing to help with this.

Many thanks in advance

 
Old June 9th, 2004, 08:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Bangalore, KA, India.
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi simflex,

I am not so good in PHP. Post here on what these functions in php do or what the posted php code does. Then we would be in a position to tell you the equivalent of that in ASP or would take off from there.

AFAIK, Curl does store the output of an URL on the browser, and as far as I understand your code there, you should be trying to write that output in to a text file. Am I right?

Cheers!

_________________________
-Vijay G
Strive for Perfection
 
Old June 10th, 2004, 11:26 AM
Registered User
 
Join Date: Jun 2004
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi Vijay!
As I understand it, libcurl allows you to connect and communicate to many different types of servers with many different types of protocols. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols.

The most basic definition of the curl library is this:

Curl is a command line tool for transferring files with URL syntax, supporting FTP, FTPS, HTTP, HTTPS, GOPHER, TELNET, DICT, FILE and LDAP. Curl supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, kerberos, HTTP form based upload, proxies, cookies, user+password authentication, file transfer resume, http proxy tunneling and a busload of other

I have read it many times hoping to have a better understanding of what it does but I am not having much luck.

As for your next question about writing an output to a textfile, that is one of the functionalities.
I believe I did that with this code;

'check if file exists, if it dosn't, create it
If not fso.FileExists("temp:\ftemp") then
    'it doesn't exist, lets create it
    set vinputfile = fso.OpentextFile("temp:\ftemp",8,true) 'open for appending with the create option on
Else
    'otherwise it exists, so just open it for appending
    Set vinputfile = fso.CreateTextFile("temp:\ftemp",False,False)

All I am trying to do now is to take whatever is stored in the textfile and send it to the browser via the http:

I believe that is what they did here with php:

$inputfile = tempnam("temp/","ftemp");

# strip web server from $img
if ( substr($img,0,5) == 'http:' )
{
  preg_match("/http:\/\/[^\/]+(\/.*)$/",$img,$match) ;
# $img = $match[1];
}

$win_array = split(" ",$win);
$w = $win_array[2] - $win_array[0];
$h = $win_array[3] - $win_array[1];
$mapsize_array = split(" ",$mapsize);
$mapext_array = split(" ",$mapext);

$vert_exag = 1.0;

#shading intensity factor
$factor = 15;

# reduced sampling factor for Elevations
$red_factor = 5.0;

#clipping bounds for elevations
$base_elev = 600;
$cap_elev = 2000;

$zspacing = ($factor * $red_factor);
$xspacing = ($factor * $red_factor);

#zoom speed realtes to workd_size
$world_size = 5;
$scale = $world_size/$mapsize_array[0];

$mapwidth = floor($mapsize_array[0]/$red_factor);
$mapheight = floor($mapsize_array[1]/$red_factor);


$ch = curl_init("http://www.gc/ms4.0/mapserv?map=/web/wms/ms/terrain/mapserv.map&mode=map&layers=dem&map_imagetype=AAIG rid&mapsize=$mapwidth+$mapheight&mapext=".str_repl ace(" ","+",$mapext));
$fp = fopen($inputfile,"w");
curl_setopt($ch,CURLOPT_FILE,$fp);
curl_setopt($ch,CURLOPT_HEADRER,0);
curl_setopt($ch,CURLOPT_VERBOSE,0);
curl_exec($ch);
curl_close($ch);
fclose($fp);

$ascii = file($inputfile);
echo "#VRML V2.0 utf8\n\n";
$ncols = 0;
$nrows = 0;


and my translation up to that point is ok, I think:

'open our log file
Dim fso, vinputfile
Set fso = CreateObject("Scripting.FileSystemObject")

'check if file exists, if it dosn't, create it
If not fso.FileExists("temp:\ftemp") then
    'it doesn't exist, lets create it
    set vinputfile = fso.OpentextFile("temp:\ftemp",8,true) 'open for appending with the create option on
Else
    'otherwise it exists, so just open it for appending
    Set vinputfile = fso.CreateTextFile("temp:\ftemp",False,False)
End If

'close our file
vinputfile.close()

'remove the references to cleanup memory
Set vinputfile = Nothing
Set fso = Nothing

' strip web server from f_img
if left(f_img,5) == "http:" then

'First, create a reg exp object
Dim objRegExp
Set objRegExp = New RegExp

objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.pattern = "<a\s+href=""http://(.*?)"">\s*((\n¦.)+?)\s*</a>"

'Now, replace the HREF tags with our preferred format
strText = objRegExp.Replace(f_img,pmatch, "f2 [http://f1]")

win_array = split(fwin," ");
w = win_array(2) - win_array(0);
h = win_array(3) - win_array(1);
mapsize_array = split(mapsize," ");
mapext_array = split(mapext," ");

vert_exag = 1.0;

'shading intensity factor
vfactor = 15;

' reduced sampling factor for Elevations
vred_factor = 5.0;

'clipping bounds for elevations
vbase_elev = 600;
vcap_elev = 2000;

vzspacing = (vfactor * vred_factor);
vxspacing = (vfactor * vred_factor);

'zoom speed realtes to workd_size
vworld_size = 5;
vscale = vworld_size/vmapsize_array(0);

vmapwidth = math.floor(vmapsize_array(0)/vred_factor);
vmapheight = math.floor(vmapsize_array(1)/vred_factor);


vch = curl_init("http://fwms.gis.fc/ms4.0/mapserv?map=/web/wms/ms/terrain/mapserv.map&mode=map&layers=dem&map_imagetype=AAIG rid&mapsize=vmapwidth+vmapheight&mapext=".str_repl ace(" ","+",vmapext));
vfp = fopen(vinputfile,"w");
curl_setopt(vch,CURLOPT_FILE,vfp);
curl_setopt(vch,CURLOPT_HEADRER,0);
curl_setopt(vch,CURLOPT_VERBOSE,0);
curl_exec(vch);
curl_close(vch);
fclose(vfp);

vascii = file(vinputfile);
Response.write("'VRML V2.0 utf8\n\n")
vncols = 0;
vnrows = 0;

Please forgive me for the dump, I am just trying to find a way to make sense.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Asp/ PHP explore_asp Classic ASP Professional 4 February 23rd, 2013 04:16 AM
Asp.net v php Ducca571 ASP.NET 2.0 Professional 3 October 23rd, 2006 11:07 AM
ASP.NET vs. PHP Aaron Edwards ASP.NET 2.0 Basics 0 May 6th, 2006 12:51 PM
ASP.NET and PHP Prabhakar_dt VB Components 0 September 9th, 2005 04:44 AM
ASP to php kobalt7 Beginning PHP 1 June 14th, 2005 03:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.