Skip to content

Commit

Permalink
Merge pull request #428 from aj-gh/partylist-improvements
Browse files Browse the repository at this point in the history
Partylist: Module improvements
  • Loading branch information
M4LuZ committed Feb 19, 2019
2 parents 8454dcc + 4392038 commit 0754a13
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 59 deletions.
13 changes: 10 additions & 3 deletions modules/partylist/Functions/AddSignonStatus.php
Expand Up @@ -7,19 +7,26 @@
*/
function AddSignonStatus($lsurl, $show_history = 0)
{
global $xml, $dsp, $HTTPHeader, $func;
global $xml, $dsp, $func;

if (substr($lsurl, strlen($lsurl) - 1, 1) != '/') {
$lsurl .= '/';
}
if (substr($lsurl, 0, 7) != 'http://') {
if (substr($lsurl, 0, 7) != 'http://' && substr($lsurl, 0, 8) != 'https://') {
$lsurl = 'http://'. $lsurl;
}
$lsurl .= 'ext_inc/party_infos/infos.xml';
$content = GetSite($lsurl);

if (!$content) {
return '<div class="infolink" style="display:inline">'. t('infos.xml fehlt') .'<span class="infobox">'. $lsurl .HTML_NEWLINE.HTML_NEWLINE. str_replace("'", "\\'", str_replace('"', "'", str_replace("\r\n", HTML_NEWLINE, $HTTPHeader))) .'</span></div>';
$content_error = '';
if (!extension_loaded('openssl') && strpos($lsurl, 'https://')!==false) {
$content_error .= HTML_NEWLINE.t('Konfigurationsproblem: OpenSSL-Modul nicht geladen');
}
if (!ini_get('allow_url_fopen')) {
$content_error .= HTML_NEWLINE.t('Konfigurationsproblem: allow_url_fopen nicht aktiv');
}
return '<div class="infolink" style="display:inline">'. t('Fehler beim Datenabruf') . $content_error .'<span class="infobox">'. $lsurl .'</span></div>';
} else {
$system = $xml->get_tag_content_array('system', $content);
// Version 3.0 XML-File
Expand Down
45 changes: 1 addition & 44 deletions modules/partylist/Functions/GetSite.php
Expand Up @@ -3,51 +3,8 @@
/**
* @param string $url
* @return bool|string
* @todo fix this to use fopen or similar to handle HTTPS and redirects
*/
function GetSite($url)
{
global $HTTPHeader;

$url = @parse_url($url);
if (!$url['port']) {
$url['port'] = 80;
}
$url['host'] = trim($url['host']);
$url['path'] = trim($url['path']);
if (!$url['host'] or !$url['path']) {
$HTTPHeader = t('Hostname, oder Pfad fehlt');
return '';
}
try {
$fp = @fsockopen($url['host'], $url['port'], $errno, $errstr, 1);
} catch (Exception $e) {
// Ignore connection errors
}

if (!$fp) {
$HTTPHeader = $errno.': '.$errstr;
return '';
} else {
$cont = '';

fputs($fp, "GET {$url['path']} HTTP/1.0\r\nHost: {$url['host']}\r\n\r\n");
while (!feof($fp)) {
$line = fgets($fp, 128);
if ($line == '') {
break;
}
$cont .= $line;
}
fclose($fp);

$HTTPHeader = substr($cont, 0, strpos($cont, "\r\n\r\n"));

$StatusCode = substr($HTTPHeader, strpos($HTTPHeader, ' ') + 1, 3);
if ($StatusCode != 200) {
return '';
}

return substr($cont, strpos($cont, "\r\n\r\n") + 4);
}
return @file_get_contents($url, false, stream_context_create(array('http' => array('timeout' => 10))));
}
41 changes: 31 additions & 10 deletions modules/partylist/mod_settings/translation.xml
Expand Up @@ -262,16 +262,6 @@
<it>Hostname o il percorso è mancante</it>
<file>partylist</file>
</entry>
<entry>
<id>e878032d6b4bb38bb67c824033583c2d</id>
<org>infos.xml fehlt</org>
<en>infos.xml missing</en>
<es>infos.xml desaparecidos</es>
<fr>infos.xml disparus</fr>
<nl>infos.xml vermist</nl>
<it>infos.xml mancanti</it>
<file>partylist</file>
</entry>
<entry>
<id>92b414b968c001a1d8358de2438d37d5</id>
<org>Noch keine Party angelegt</org>
Expand Down Expand Up @@ -392,6 +382,37 @@
<it>Nessuna voce</it>
<file>partylist</file>
</entry>
<entry>
<id>31c82656054fa9ec750f5deedccec884</id>
<org>Fehler beim Datenabruf</org>
<en>Error while retrieving data</en>
<es>Error al recuperar datos</es>
<fr>Erreur lors de la récupération des données</fr>
<nl>Fout tijdens het ophalen van gegevens</nl>
<it>Errore durante il recupero dei dati</it>
<file>partylist</file>
</entry>
<entry>
<id>f0fb3c160b2babab82fef748e09411a3</id>
<org>Konfigurationsproblem: OpenSSL-Modul nicht geladen</org>
<en>Configuration problem: OpenSSL module not loaded</en>
<es>Configuration problem: OpenSSL module not loaded</es>
<fr>Configuration problem: OpenSSL module not loaded</fr>
<nl>Configuration problem: OpenSSL module not loaded</nl>
<it>Configuration problem: OpenSSL module not loaded</it>
<file>partylist</file>
</entry>
<entry>
<id>b52e743a00f414c366f87db86928e143</id>
<org>Konfigurationsproblem: allow_url_fopen nicht aktiv</org>
<en>Configuration problem: allow_url_fopen not enabled</en>
<es>Configuration problem: allow_url_fopen not enabled</es>
<fr>Configuration problem: allow_url_fopen not enabled</fr>
<nl>Configuration problem: allow_url_fopen not enabled</nl>
<it>Configuration problem: allow_url_fopen not enabled</it>
<file>partylist</file>
</entry>

</content>
</table>
</lansuite>
4 changes: 2 additions & 2 deletions modules/partylist/show.php
Expand Up @@ -8,7 +8,7 @@
if (substr($row['ls_url'], strlen($row['ls_url']) - 1, 1) != '/') {
$row['ls_url'] .= '/';
}
if (substr($row['ls_url'], 0, 7) != 'http://') {
if (substr($row['ls_url'], 0, 7) != 'http://' && substr($row['ls_url'], 0, 8) != 'https://') {
$row['ls_url'] = 'http://'. $row['ls_url'];
}
header('Location: '. $row['ls_url'] . 'index.php?mod=signon');
Expand Down Expand Up @@ -62,7 +62,7 @@
p.partyid = %int%", $_GET['partyid']);
$framework->AddToPageTitle($row["name"]);

if (substr($row['url'], 0, 7) != 'http://') {
if (substr($row['url'], 0, 7) != 'http://' && substr($row['url'], 0, 8) != 'https://') {
$row['url'] = 'http://'. $row['url'];
}

Expand Down

0 comments on commit 0754a13

Please sign in to comment.