- fixing RootDir in ApsInstaller and ApsUpdater, fixes #14 and #15

- fixed root_db connection in openRootDB()
This commit is contained in:
Michael Kaufmann (d00p)
2010-02-15 12:05:15 +00:00
parent 74e3ed0a1f
commit 0488a3c2a4
4 changed files with 98 additions and 91 deletions

View File

@@ -45,7 +45,7 @@ class ApsInstaller extends ApsParser
{ {
$this->db = $db; $this->db = $db;
$this->db_root = $db_root; $this->db_root = $db_root;
$this->RootDir = dirname(dirname(__FILE__)) . '/'; $this->RootDir = dirname(dirname(dirname(dirname(__FILE__)))) . '/';
$this->Hosts = $settings['system']['mysql_access_host']; $this->Hosts = $settings['system']['mysql_access_host'];
} }

View File

@@ -43,7 +43,7 @@ class ApsUpdater extends ApsParser
$this->db = $db; $this->db = $db;
$this->RequestDomain = 'apscatalog.com'; $this->RequestDomain = 'apscatalog.com';
$this->RootUrl = '/1/'; $this->RootUrl = '/1/';
$this->RootDir = dirname(dirname(__FILE__)) . '/'; $this->RootDir = dirname(dirname(dirname(dirname(__FILE__)))) . '/';
} }
/** /**
@@ -56,9 +56,9 @@ class ApsUpdater extends ApsParser
//return if allow_url_fopen is disabled //return if allow_url_fopen is disabled
if(ini_get('allow_url_fopen') == '0') if(!ini_get('allow_url_fopen'))
{ {
echo ("The APS updater cronjob requires that allow_url_fopen is enabled for the PHP CLI binary!\n"); echo "The APS updater cronjob requires that allow_url_fopen is enabled for the PHP CLI binary!\n";
return; return;
} }
@@ -79,11 +79,15 @@ class ApsUpdater extends ApsParser
//fetch all vendors //fetch all vendors
$Vendors = self::FetchSubUrls($this->RootUrl); $Vendors = self::FetchSubUrls($this->RootUrl);
if($Vendors !== false)
{
foreach($Vendors as $Vendor) foreach($Vendors as $Vendor)
{ {
//fetch all applications from vendors //fetch all applications from vendors
$Applications = self::FetchSubUrls($this->RootUrl . $Vendor); $Applications = self::FetchSubUrls($this->RootUrl . $Vendor);
if($Applications !== false)
{
foreach($Applications as $Application) foreach($Applications as $Application)
{ {
//get newest version of package which is already installed //get newest version of package which is already installed
@@ -109,6 +113,8 @@ class ApsUpdater extends ApsParser
$NewerVersion = ''; $NewerVersion = '';
$Versions = self::FetchSubUrls($this->RootUrl . $Vendor . $Application); $Versions = self::FetchSubUrls($this->RootUrl . $Vendor . $Application);
if($Versions !== false)
{
foreach($Versions as $Version) foreach($Versions as $Version)
{ {
$OnlineVersion = substr($Version, 0, -1); $OnlineVersion = substr($Version, 0, -1);
@@ -134,6 +140,7 @@ class ApsUpdater extends ApsParser
continue; continue;
} }
} }
}
else else
{ {
if($Task['Task'] != TASK_SYSTEM_DOWNLOAD)continue; if($Task['Task'] != TASK_SYSTEM_DOWNLOAD)continue;
@@ -165,6 +172,8 @@ class ApsUpdater extends ApsParser
} }
} }
} }
}
}
/** /**
* download a package from the distribution server and move the downloaded file in the temporary directory * download a package from the distribution server and move the downloaded file in the temporary directory
@@ -236,7 +245,7 @@ class ApsUpdater extends ApsParser
$Content = @file('http://' . $this->RequestDomain . $Url); $Content = @file('http://' . $this->RequestDomain . $Url);
if($Content != false) if($Content !== false)
{ {
foreach($Content as $Temp) foreach($Content as $Temp)
{ {

View File

@@ -30,10 +30,7 @@ function openRootDB($debugHandler, $lockfile)
{ {
global $db_root; global $db_root;
// If one cronscript needs root, it should say $needrootdb = true before the include require ('./lib/userdata.inc.php');
if(isset($needrootdb)
&& $needrootdb === true)
{
$db_root = new db($sql_root[0]['host'], $sql_root[0]['user'], $sql_root[0]['password'], ''); $db_root = new db($sql_root[0]['host'], $sql_root[0]['user'], $sql_root[0]['password'], '');
if($db_root->link_id == 0) if($db_root->link_id == 0)
@@ -49,7 +46,8 @@ function openRootDB($debugHandler, $lockfile)
unset($db_root->password); unset($db_root->password);
fwrite($debugHandler, 'Database-rootconnection established' . "\n"); fwrite($debugHandler, 'Database-rootconnection established' . "\n");
}
unset($sql);
} }
function closeRootDB() function closeRootDB()

View File

@@ -134,7 +134,7 @@ function showUpdateStep($task = null, $needs_status = true)
* outputs [OK] (success), [??] (warning) or [!!] (failure) * outputs [OK] (success), [??] (warning) or [!!] (failure)
* of the last update-step * of the last update-step
* *
* @param int status (0 = success, 1 = warning, -1 = failure) * @param int status (0 = success, 1 = warning, 2 = failure)
* *
* @return string formatted output and log-entry * @return string formatted output and log-entry
*/ */