Loading a deleted file using Curl (Script or PHP)

cURL is a library for transferring files over the Internet or another network, allowing you to send or receive them over all current protocols (http, ftp, ldap).

This is an alternative to fsockopen. It is implemented in PHP and can also be used in C and C++.

  1. Check curl availability on web hosting.
  2. Include cURL in XAMPP.
  3. Use cURL with script
  4. Use cURL with PHP
  5. Use cURL for RSS drive.

1) Check cURL availability on web hosting

The phpinfo () function displays the active libraries on the server.
Install the following script on the hosting:

<?php  echo phpinfo();?>

If cURL is enabled, the following table will be displayed:

2) Enable cURL under local server (e.g. XAMPP)

cURL is not enabled by default in PHP, this must be done manually. There is a command in the menu for this, but it only affects the configuration of PHP only, and not in the Apache directory.
On Xampp, you need to change the PHP.INI file of both:

c:\xampp\php\php5.3.0\php.ini
c:\xampp\apache\Apache2.2.11\bin\php.ini 

The following line should be commented in both files:

extension=php_curl.dll 

Make sure you have libeay32.dll and sssleay32.dll.

3) Use cURL with Script

To use cURL with a script that compiles in PHP, you need to add a variable and function definition file. This interface with PHP functions is available in the archive (see below):

extern
dyn curl_init(cstring curlopt = null)
boolean curl_setopt(dyn, int, dyn)
dyn curl_exec(dyn)
void curl_close(dyn)
array curl_version()
constant int CURLOPT_URL // pass URL
constant int CURLOPT_CONNECTTIMEOUT // limit waiting time forever
constant int CURLOPT_UPLOAD // send file
/extern

There are many other variables that you yourself will define in accordance with his needs with the following lines:

constant int CURLOPT_xxx

Two scenarios are included in the archive:

curl-check.sol-Checks cURL availability, displays available version and functions.
curl-demo.sol-Reads the RSS feed on the remote server.

4) Use cURL with PHP

Use cURL to open a session with curl_init () and specify the type of operation to be performed with curl_setopt ().

curl_exec () starts execution and the session is closed curl_close ().

The PHP guide describes the use of cURLs with examples and indicates all possible options.

5) Use cURL with RSS drive

As it became known on the forum, it happens that the cross-hosting server does not allow access to another site, and if you want to integrate an RSS feed, then this is impossible using DOMDocument-> load or fsockopen becomes possible using cURL.

This string will be replaced in the RSS_retrieve function:

$doc->load($url);

by:

$hnd = curl_init();
curl_setopt($hnd, CURLOPT_CONNECTTIMEOUT, 300);
curl_setopt($hnd, CURLOPT_URL, $url);
$data = curl_exec($hnd);
curl_close($hnd); $doc->loadXML($data);

See RSS Reader.

Download the cURL interface and demo.