Skip to content

Commit

Permalink
feature 2057: use $get_data parameter to send GET data.
Browse files Browse the repository at this point in the history
git-svn-id: http://piwigo.org/svn/trunk@8083 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
patdenice committed Dec 11, 2010
1 parent 4ae5122 commit ea64e42
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 39 deletions.
32 changes: 21 additions & 11 deletions admin/include/languages.class.php
Expand Up @@ -196,13 +196,16 @@ function get_server_languages()
{
global $user;

$pem_category_id = 8;
$get_data = array(
'category_id' => 8,
'format' => 'php',
);

// Retrieve PEM versions
$version = PHPWG_VERSION;
$versions_to_check = array();
$url = PEM_URL . '/api/get_version_list.php?category_id='.$pem_category_id.'&format=php';
if (fetchRemote($url, $result) and $pem_versions = @unserialize($result))
$url = PEM_URL . '/api/get_version_list.php';
if (fetchRemote($url, $result, $get_data) and $pem_versions = @unserialize($result))
{
if (!preg_match('/^\d+\.\d+\.\d+/', $version))
{
Expand All @@ -223,11 +226,15 @@ function get_server_languages()
}

// Retrieve PEM languages infos
$url = PEM_URL . '/api/get_revision_list.php?category_id='.$pem_category_id.'&format=php&last_revision_only=true';
$url .= '&version=' . implode(',', $versions_to_check);
$url .= '&lang='.$user['language'];

if (fetchRemote($url, $result))
$url = PEM_URL . '/api/get_revision_list.php';
$get_data = array_merge($get_data, array(
'last_revision_only' => 'true',
'version' => implode(',', $versions_to_check),
'lang' => $user['language'],
)
);

if (fetchRemote($url, $result, $get_data))
{
$pem_languages = @unserialize($result);
if (!is_array($pem_languages))
Expand Down Expand Up @@ -258,10 +265,13 @@ function extract_language_files($action, $revision, $dest='')
{
if ($archive = tempnam( PHPWG_ROOT_PATH.'language', 'zip'))
{
$url = PEM_URL . '/download.php?rid=' . $revision;
$url .= '&origin=piwigo_' . $action;
$url = PEM_URL . '/download.php';
$get_data = array(
'rid' => $revision,
'origin' => 'piwigo_'.$action,
);

if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle))
if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle, $get_data))
{
fclose($handle);
include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
Expand Down
42 changes: 30 additions & 12 deletions admin/include/plugins.class.php
Expand Up @@ -290,11 +290,16 @@ function get_server_plugins($new=false)
{
global $user;

$get_data = array(
'category_id' => 12,
'format' => 'php',
);

// Retrieve PEM versions
$version = PHPWG_VERSION;
$versions_to_check = array();
$url = PEM_URL . '/api/get_version_list.php?category_id=12&format=php';
if (fetchRemote($url, $result) and $pem_versions = @unserialize($result))
$url = PEM_URL . '/api/get_version_list.php';
if (fetchRemote($url, $result, $get_data) and $pem_versions = @unserialize($result))
{
if (!preg_match('/^\d+\.\d+\.\d+/', $version))
{
Expand Down Expand Up @@ -325,17 +330,27 @@ function get_server_plugins($new=false)
}

// Retrieve PEM plugins infos
$url = PEM_URL . '/api/get_revision_list.php?category_id=12&format=php&last_revision_only=true';
$url .= '&version=' . implode(',', $versions_to_check);
$url .= '&lang=' . substr($user['language'], 0, 2);
$url .= '&get_nb_downloads=true';
$url = PEM_URL . '/api/get_revision_list.php';
$get_data = array_merge($get_data, array(
'last_revision_only' => 'true',
'version' => implode(',', $versions_to_check),
'lang' => substr($user['language'], 0, 2),
'get_nb_downloads' => 'true',
)
);

if (!empty($plugins_to_check))
{
$url .= $new ? '&extension_exclude=' : '&extension_include=';
$url .= implode(',', $plugins_to_check);
if ($new)
{
$get_data['extension_exclude'] = implode(',', $plugins_to_check);
}
else
{
$get_data['extension_include'] = implode(',', $plugins_to_check);
}
}
if (fetchRemote($url, $result))
if (fetchRemote($url, $result, $get_data))
{
$pem_plugins = @unserialize($result);
if (!is_array($pem_plugins))
Expand Down Expand Up @@ -386,10 +401,13 @@ function extract_plugin_files($action, $revision, $dest)
{
if ($archive = tempnam( PHPWG_PLUGINS_PATH, 'zip'))
{
$url = PEM_URL . '/download.php?rid=' . $revision;
$url .= '&origin=piwigo_' . $action;
$url = PEM_URL . '/download.php';
$get_data = array(
'rid' => $revision,
'origin' => 'piwigo_'.$action,
);

if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle))
if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle, $get_data))
{
fclose($handle);
include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
Expand Down
42 changes: 29 additions & 13 deletions admin/include/themes.class.php
Expand Up @@ -447,13 +447,16 @@ function get_server_themes($new=false)
{
global $user;

$pem_category_id = 10;
$get_data = array(
'category_id' => 10,
'format' => 'php',
);

// Retrieve PEM versions
$version = PHPWG_VERSION;
$versions_to_check = array();
$url = PEM_URL . '/api/get_version_list.php?category_id='.$pem_category_id.'&format=php';
if (fetchRemote($url, $result) and $pem_versions = @unserialize($result))
$url = PEM_URL . '/api/get_version_list.php';
if (fetchRemote($url, $result, $get_data) and $pem_versions = @unserialize($result))
{
if (!preg_match('/^\d+\.\d+\.\d+/', $version))
{
Expand Down Expand Up @@ -484,17 +487,27 @@ function get_server_themes($new=false)
}

// Retrieve PEM themes infos
$url = PEM_URL . '/api/get_revision_list.php?category_id='.$pem_category_id.'&format=php&last_revision_only=true';
$url .= '&version=' . implode(',', $versions_to_check);
$url .= '&lang=' . substr($user['language'], 0, 2);
$url .= '&get_nb_downloads=true';
$url = PEM_URL . '/api/get_revision_list.php';
$get_data = array_merge($get_data, array(
'last_revision_only' => 'true',
'version' => implode(',', $versions_to_check),
'lang' => substr($user['language'], 0, 2),
'get_nb_downloads' => 'true',
)
);

if (!empty($themes_to_check))
{
$url .= $new ? '&extension_exclude=' : '&extension_include=';
$url .= implode(',', $themes_to_check);
if ($new)
{
$get_data['extension_exclude'] = implode(',', $themes_to_check);
}
else
{
$get_data['extension_include'] = implode(',', $themes_to_check);
}
}
if (fetchRemote($url, $result))
if (fetchRemote($url, $result, $get_data))
{
$pem_themes = @unserialize($result);
if (!is_array($pem_themes))
Expand Down Expand Up @@ -546,10 +559,13 @@ function extract_theme_files($action, $revision, $dest)
{
if ($archive = tempnam( PHPWG_THEMES_PATH, 'zip'))
{
$url = PEM_URL . '/download.php?rid=' . $revision;
$url .= '&origin=piwigo_' . $action;
$url = PEM_URL . '/download.php';
$get_data = array(
'rid' => $revision,
'origin' => 'piwigo_'.$action,
);

if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle))
if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle, $get_data))
{
fclose($handle);
include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
Expand Down
8 changes: 5 additions & 3 deletions admin/site_manager.php
Expand Up @@ -116,9 +116,11 @@ function remote_output($url)
if ( ! isset($_POST['no_check']) )
{
$clf_url = $url.'create_listing_file.php';
$clf_url.= '?action=test';
$clf_url.= '&version='.PHPWG_VERSION;
if (fetchRemote($clf_url, $result))
$get_data = array(
'action' => 'test',
'version' => PHPWG_VERSION,
);
if (fetchRemote($clf_url, $result, $get_data))
{
$lines = explode("\r\n", $result);
$first_line = strip_tags($lines[0]);
Expand Down

0 comments on commit ea64e42

Please sign in to comment.