Hallo!
Mir wurde ja ans Herzen gelegt die
getPackInfo()-Methode mal zu überarbeiten. Das ist auch geschehen, doch gibt es ein kleines Problem. Und zwar habe ich eine control.txt, die wie folgt aussieht:
control.csv
Code:
Package: blubb blubb
Version: 1.0.1
Depends: blubb 1, haha 2, buhh 3
Suggests: blubb_master
Installed-Size: 5
Author: Andreas Wilhelm <andreas@mail.de>
Description: you are the master with this
Package: lollig
Version: 0.3.4
Depends: lol1, lol2
Suggests: lol_minion
Installed-Size: 14
Author: Andreas Wilhelm <andreas@mail.de>
Description: everxbody will laugh at you
Die Methode gibt also ein Array zurück. Das funktioniert auch, jedoch enthält dieses Array nur den zweiten Eintrag und nicht auch den ersten, wie es eigentlich gewünscht ist. Wo liegt mein Fehler? Bin für jede Hilfe dankbar.
MfG, Andy
PS:
$path ist momentan noch konstant und die Variable
$server wird nicht genutzt, das liegt daran, dass auf meinem Server, wie wohl auch auf vielen anderen,
allow_url_fopen auf
off steht. Daher muss ich erst die HTTP-Klasse fertigstellen, um das ändern zu können. Es geht aber momentan ja auch nur um die Ausgabe.
getPackInfo()
PHP-Code:
/**
* getPackInfo() - Gets the information about the different packages
*
* @access: public
* @return Array
*/
public function getPackInfo()
{
$host = $this->getRepos();
foreach( $host as $server => $pwd)
{
// path to the file that contains the package-information
$path = 'public/control.txt';
// get content of the package-information-file
$file = file_get_contents($path);
// separate package-information-blocks
$block = split("\r\n\r\n", $file);
$package = array();
foreach($block as $key => $info)
{
// save information to an array
if( preg_match_all('#(.*): (.*)\n#U', $info, $result) )
{
$num = count($result[0]);
for($i=0; $i<$num; $i++)
{
$name = $result[1][$i];
$info = $result[2][$i];
$package[$name] = $info;
}
}
$package['url'] = "$server/$path";
}
}
return $package;
}