Permalink
Browse files

Merge branch 'master' of git://github.com/osCommerce/oscommerce

  • Loading branch information...
2 parents 70154a2 + 557563e commit 7744c3bbd237d12f200244d4d7c11b6f59ba7403 @tgely committed Apr 15, 2011
@@ -8,38 +8,63 @@
namespace osCommerce\OM\Core\HttpRequest;
+ use osCommerce\OM\Core\HttpRequest;
+
class Curl {
public static function execute($parameters) {
$curl = curl_init($parameters['server']['scheme'] . '://' . $parameters['server']['host'] . $parameters['server']['path'] . (isset($parameters['server']['query']) ? '?' . $parameters['server']['query'] : ''));
- curl_setopt($curl, CURLOPT_PORT, $parameters['server']['port']);
+ $curl_options = array(CURLOPT_PORT => $parameters['server']['port'],
+ CURLOPT_HEADER => true,
+ CURLOPT_SSL_VERIFYPEER => false,
+ CURLOPT_RETURNTRANSFER => true,
+ CURLOPT_FORBID_REUSE => true,
+ CURLOPT_FRESH_CONNECT => true,
+ CURLOPT_FOLLOWLOCATION => false);
if ( !empty($parameters['header']) ) {
- curl_setopt($curl, CURLOPT_HTTPHEADER, $parameters['header']);
+ $curl_options[CURLOPT_HTTPHEADER] = $parameters['header'];
}
if ( !empty($parameters['certificate']) ) {
- curl_setopt($curl, CURLOPT_SSLCERT, $parameters['certificate']);
+ $curl_options[CURLOPT_SSLCERT] = $parameters['certificate'];
}
- curl_setopt($curl, CURLOPT_HEADER, 0);
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($curl, CURLOPT_FORBID_REUSE, 1);
- curl_setopt($curl, CURLOPT_FRESH_CONNECT, 1);
- curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($curl, CURLOPT_MAXREDIRS, 5);
-
if ( $parameters['method'] == 'post' ) {
- curl_setopt($curl, CURLOPT_POST, 1);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $parameters['parameters']);
+ $curl_options[CURLOPT_POST] = true;
+ $curl_options[CURLOPT_POSTFIELDS] = $parameters['parameters'];
}
+ curl_setopt_array($curl, $curl_options);
$result = curl_exec($curl);
+ $http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
+
curl_close($curl);
- return $result;
+ list($headers, $body) = explode("\r\n\r\n", $result, 2);
+
+ if ( ($http_code == 301) || ($http_code == 302) ) {
+ if ( !isset($parameters['redir_counter']) || ($parameters['redir_counter'] < 6) ) {
+ if ( !isset($parameters['redir_counter']) ) {
+ $parameters['redir_counter'] = 0;
+ }
+
+ $matches = array();
+ preg_match('/(Location:|URI:)(.*?)\n/i', $headers, $matches);
+
+ $redir_url = trim(array_pop($matches));
+
+ $parameters['redir_counter']++;
+
+ $redir_params = array('url' => $redir_url,
+ 'redir_counter', $parameters['redir_counter']);
+
+ $body = HttpRequest::getResponse($redir_params, 'Curl');
+ }
+ }
+
+ return $body;
}
public static function canUse() {
@@ -58,9 +58,9 @@
<td align="right"><img src="<?php echo OSCOM::getPublicSiteLink('templates/default/images/' . (((int)ini_get('register_globals') === 0) ? 'tick.gif' : 'cross.gif')); ?>" alt="" border="0" width="16" height="16" /></td>
</tr>
<tr>
- <td><?php echo OSCOM::getDef('box_server_magic_quotes'); ?></td>
- <td align="right"><?php echo (((int)ini_get('magic_quotes') === 0) ? OSCOM::getDef('box_server_off') : OSCOM::getDef('box_server_on')); ?></td>
- <td align="right"><img src="<?php echo OSCOM::getPublicSiteLink('templates/default/images/' . (((int)ini_get('magic_quotes') === 0) ? 'tick.gif' : 'cross.gif')); ?>" alt="" border="0" width="16" height="16" /></td>
+ <td><?php echo OSCOM::getDef('box_server_magic_quotes_gpc'); ?></td>
+ <td align="right"><?php echo (((int)ini_get('magic_quotes_gpc') === 0) ? OSCOM::getDef('box_server_off') : OSCOM::getDef('box_server_on')); ?></td>
+ <td align="right"><img src="<?php echo OSCOM::getPublicSiteLink('templates/default/images/' . (((int)ini_get('magic_quotes_gpc') === 0) ? 'tick.gif' : 'cross.gif')); ?>" alt="" border="0" width="16" height="16" /></td>
</tr>
<tr>
<td><?php echo OSCOM::getDef('box_server_file_uploads'); ?></td>
@@ -73,13 +73,13 @@ function prepareDB() {
$('#mBox').css('visibility', 'visible').show();
$('#mBoxContents').html('<p><img src="<?php echo OSCOM::getPublicSiteLink('templates/default/images/progress.gif'); ?>" align="right" hspace="5" vspace="5" border="0" /><?php echo OSCOM::getDef('rpc_database_connection_test'); ?></p>');
- dbServer = $('#DB_SERVER').val();
- dbUsername = $('#DB_SERVER_USERNAME').val();
- dbPassword = $('#DB_SERVER_PASSWORD').val();
- dbName = $('#DB_DATABASE').val();
- dbPort = $('#DB_SERVER_PORT').val();
- dbClass = $('#DB_DATABASE_CLASS').val();
- dbPrefix = $('#DB_TABLE_PREFIX').val();
+ dbServer = encodeURIComponent($('#DB_SERVER').val());
+ dbUsername = encodeURIComponent($('#DB_SERVER_USERNAME').val());
+ dbPassword = encodeURIComponent($('#DB_SERVER_PASSWORD').val());
+ dbName = encodeURIComponent($('#DB_DATABASE').val());
+ dbPort = encodeURIComponent($('#DB_SERVER_PORT').val());
+ dbClass = encodeURIComponent($('#DB_DATABASE_CLASS').val());
+ dbPrefix = encodeURIComponent($('#DB_TABLE_PREFIX').val());
$.post('<?php echo OSCOM::getRPCLink(null, null, 'DBCheck'); ?>',
'server=' + dbServer + '&username=' + dbUsername + '&password=' + dbPassword + '&name=' + dbName + '&port=' + dbPort + '&class=' + dbClass,
@@ -72,11 +72,11 @@ function prepareDB() {
$('#mBox').css('visibility', 'visible').show();
$('#mBoxContents').html('<p><img src="<?php echo OSCOM::getPublicSiteLink('templates/default/images/progress.gif'); ?>" align="right" hspace="5" vspace="5" border="0" /><?php echo OSCOM::getDef('rpc_database_store_configuration'); ?></p>');
- shopName = $('#CFG_STORE_NAME').val();
- shopOwnerName = $('#CFG_STORE_OWNER_NAME').val();
- shopOwnerEmail = $('#CFG_STORE_OWNER_EMAIL_ADDRESS').val();
- adminUsername = $('#CFG_ADMINISTRATOR_USERNAME').val();
- adminPassword = $('#CFG_ADMINISTRATOR_PASSWORD').val();
+ shopName = encodeURIComponent($('#CFG_STORE_NAME').val());
+ shopOwnerName = encodeURIComponent($('#CFG_STORE_OWNER_NAME').val());
+ shopOwnerEmail = encodeURIComponent($('#CFG_STORE_OWNER_EMAIL_ADDRESS').val());
+ adminUsername = encodeURIComponent($('#CFG_ADMINISTRATOR_USERNAME').val());
+ adminPassword = encodeURIComponent($('#CFG_ADMINISTRATOR_PASSWORD').val());
$.post('<?php echo OSCOM::getRPCLink(null, null, 'DBConfigureShop'); ?>',
'server=' + dbServer + '&username=' + dbUsername + '&password=' + dbPassword + '&name=' + dbName + '&port=' + dbPort + '&class=' + dbClass + '&prefix=' + dbPrefix + '&shop_name=' + shopName + '&shop_owner_name=' + shopOwnerName + '&shop_owner_email=' + shopOwnerEmail + '&admin_username=' + adminUsername + '&admin_password=' + adminPassword,
@@ -17,7 +17,7 @@
box_server_php_version = PHP Version
box_server_php_settings = PHP Settings
box_server_register_globals = register_globals
-box_server_magic_quotes = magic_quotes
+box_server_magic_quotes_gpc = magic_quotes_gpc
box_server_file_uploads = file_uploads
box_server_session_auto_start = session.auto_start
box_server_session_use_trans_sid = session.use_trans_sid

0 comments on commit 7744c3b

Please sign in to comment.