Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
1aa55357
Commit
1aa55357
authored
12 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
New: Add function to get http content
parent
c1dd2f20
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/core/lib/geturl.lib.php
+101
-0
101 additions, 0 deletions
htdocs/core/lib/geturl.lib.php
with
101 additions
and
0 deletions
htdocs/core/lib/geturl.lib.php
0 → 100644
+
101
−
0
View file @
1aa55357
<?php
/* Copyright (C) 2008-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2008-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/lib/functions2.lib.php
* \brief A set of functions for Dolibarr
* This file contains all rare functions.
*/
/**
* Function get content from an URL (use proxy if proxy defined)
*
* @param string $url URL to call.
* @param string $postorget 'post' = POST, 'get='GET'
* @return array returns an associtive array containing the response from the server.
*/
function
getURLContent
(
$url
,
$postorget
=
'GET'
,
$param
)
{
//declaring of global variables
global
$conf
,
$langs
;
global
$USE_PROXY
,
$PROXY_HOST
,
$PROXY_PORT
,
$PROXY_USER
,
$PROXY_PASS
;
dol_syslog
(
"getURLContent URL="
.
$url
);
//setting the curl parameters.
$ch
=
curl_init
();
/*print $API_Endpoint."-".$API_version."-".$PAYPAL_API_USER."-".$PAYPAL_API_PASSWORD."-".$PAYPAL_API_SIGNATURE."<br>";
print $USE_PROXY."-".$gv_ApiErrorURL."<br>";
print $nvpStr;
exit;*/
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
curl_setopt
(
$ch
,
CURLOPT_VERBOSE
,
1
);
curl_setopt
(
$ch
,
CURLOPT_SSLVERSION
,
3
);
// Force SSLv3
//turning off the server and peer verification(TrustManager Concept).
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
FALSE
);
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
FALSE
);
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
if
(
$postorget
==
'POST'
)
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
else
curl_setopt
(
$ch
,
CURLOPT_POST
,
0
);
//if USE_PROXY constant set to TRUE in Constants.php, then only proxy will be enabled.
if
(
$USE_PROXY
)
{
dol_syslog
(
"getURLContent set proxy to "
.
$PROXY_HOST
.
":"
.
$PROXY_PORT
.
" - "
.
$PROXY_USER
.
":"
.
$PROXY_PASS
);
//curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); // Curl 7.10
curl_setopt
(
$ch
,
CURLOPT_PROXY
,
$PROXY_HOST
.
":"
.
$PROXY_PORT
);
if
(
$PROXY_USER
)
curl_setopt
(
$ch
,
CURLOPT_PROXYUSERPWD
,
$PROXY_USER
.
":"
.
$PROXY_PASS
);
}
dol_syslog
(
"getURLContent param="
.
$param
);
//setting the nvpreq as POST FIELD to curl
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$param
);
//getting response from server
$response
=
curl_exec
(
$ch
);
$rep
=
array
();
$rep
[
'content'
]
=
$response
;
$rep
[
'curl_error_no'
]
=
''
;
$rep
[
'curl_error_msg'
]
=
''
;
dol_syslog
(
"getURLContent response="
.
$response
);
if
(
curl_errno
(
$ch
))
{
// moving to display page to display curl errors
$rep
[
'curl_error_no'
]
=
curl_errno
(
$ch
);
$rep
[
'curl_error_msg'
]
=
curl_error
(
$ch
);
//Execute the Error handling module to display errors.
}
else
{
//closing the curl
curl_close
(
$ch
);
}
return
$rep
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment