Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Advice on a server app

Posted on 2004-08-19
11
Medium Priority
?
245 Views
Last Modified: 2012-05-05
This may seem odd but it is what I want to do.

Scenario:
I have an account on a web server with the usual stuff available, perl, PHP, MYSQL and maybe FP extensions (don't use them so haven't noticed).

What I want to have is a web page where I can input a URL for a file on another web server. My web server will then download this file and then convert it from Binary to ASCII (text) (don't ask) and then make it available for download.

What I would like advice on is the best way to go about achieving this using the tools available to me, to complicate matters I would not call myself overly competent in perl or PHP although I have adjusted many perl scripts over the years as the need arose. Imbedded VBS could be an option as the site will only be accesses with IE but ASP is not an option here due to server config.

I am happy to become competent in perl or PHP if that is the way to go so I'm not afraid learning a new skill, my current areas of expertise are in TSQL and VB at the moment.

Any helpful advice would be greatly appreciated.

Cheers
Marcus
0
Comment
Question by:xSinbad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
11 Comments
 
LVL 1

Expert Comment

by:ch0c
ID: 11849122
Marcus,

You can do this easily with PHP. Just open a socket connection to the website and read the file. You can then do a byte by byte conversion to ASCII. It's probably a good idea to learn PHP before doing this, so you can at least fix any problems you might have.

You can find information on PHP sockets at http://www.php.net/manual/en/ref.sockets.php

Good luck.
0
 
LVL 6

Author Comment

by:xSinbad
ID: 11849570
Cheers ch0c I will check that out as it sounds pretty good to me, I didnt know PHP was that flexible.
0
 
LVL 6

Author Comment

by:xSinbad
ID: 11857029
Ok ch0c can you provide a little more guidence on this please.

I have tried this example ;

<?php
error_reporting(E_ALL);

echo "<h2>TCP/IP Connection</h2>\n";

/* Get the port for the WWW service. */
$service_port = getservbyname('www', 'tcp');

/* Get the IP address for the target host. */
$address = gethostbyname('www.google.com');

/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket < 0) {
   echo "socket_create() failed: reason: " . socket_strerror($socket) . "\n";
} else {
   echo "OK.\n";
}

echo "Attempting to connect to '$address' on port '$service_port'...";
$result = socket_connect($socket, $address, $service_port);
if ($result < 0) {
   echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
} else {
   echo "OK.\n";
}

$in = "HEAD / HTTP/1.1\r\n";
$in .= "Host: www.google.com\r\n";
$in .= "Connection: Close\r\n\r\n";
$out = '';

echo "Sending HTTP HEAD request...";
socket_write($socket, $in, strlen($in));
echo "OK.\n";

echo "Reading response:\n\n";
while ($out = socket_read($socket, 2048)) {
   echo $out;
}

echo "Closing socket...";
socket_close($socket);
echo "OK.\n\n";
?>


but get an error ;


Fatal error: Call to undefined function socket_create() in D:\Dev\index.php on line 21
Line 21 is this one :- $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
0
Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

 
LVL 1

Expert Comment

by:ch0c
ID: 11857124
Do you have PHP 5.0.0 or later installed? Sockets support was only added in 5.0.0.
0
 
LVL 6

Author Comment

by:xSinbad
ID: 11857609
I downloaded and installed the latest version yesterday.
0
 
LVL 1

Expert Comment

by:ch0c
ID: 11857659
Make sure 'php_sockets.dll' is in your PHP directory somewhere. Also, make sure that in your php.ini file you can find the following line:

extension=php_sockets.dll

If there's a semicolon in front of it, remove the semicolon.

Hope this helps.
0
 
LVL 6

Author Comment

by:xSinbad
ID: 11861752
Ok there was no ini file active but there was a php.ini.recommend which I renamed to php.ini and now php doesnt work at all....!!!

0
 
LVL 1

Accepted Solution

by:
ch0c earned 1000 total points
ID: 11861791
Try making a copy of php.ini.recommend and renaming it php.ini.

Also, try checking both files for the 'extension=php_sockets.dll' line.
0
 
LVL 6

Author Comment

by:xSinbad
ID: 11862013
Thats what I did and now PHP doesnt work at all, but it mostly worked fine without any php.ini file.
0
 
LVL 6

Author Comment

by:xSinbad
ID: 11862023
ch0c this sockets methods seems a bit complicated to implement considering I dont have access to the PHP ini on my web server, I have open another question in the PHP section and I seem to making greater progress using the methods recommended in there maybe you could help with that http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_21101863.html
0
 
LVL 6

Author Comment

by:xSinbad
ID: 11919476
Dude how about a little help with the converting of bin into ascii?
0

Featured Post

Video: Liquid Web Managed WordPress Comparisons

If you run run a WordPress, you understand the potential headaches you may face when updating your plugins and themes. Do you choose to update on the fly and risk taking down your site; or do you set up a staging, keep it in sync with your live site and use that to test updates?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question