Esempio n. 1
0
 static function getCheckUpdate()
 {
     global $zdbh, $controller, $zlo;
     $module_path = "./modules/" . $controller->GetControllerRequest('URL', 'module');
     // Get Update URL and Version From module.xml
     $mod_xml = "./modules/" . $controller->GetControllerRequest('URL', 'module') . "/module.xml";
     $mod_config = new xml_reader(fs_filehandler::ReadFileContents($mod_xml));
     $mod_config->Parse();
     $module_updateurl = $mod_config->document->updateurl[0]->tagData;
     $module_version = $mod_config->document->version[0]->tagData;
     // Download XML in Update URL and get Download URL and Version
     $myfile = check_remote_xml($module_updateurl, $module_path . "/" . $controller->GetControllerRequest('URL', 'module') . ".xml");
     $update_config = new xml_reader(fs_filehandler::ReadFileContents($module_path . "/" . $controller->GetControllerRequest('URL', 'module') . ".xml"));
     $update_config->Parse();
     $update_url = $update_config->document->downloadurl[0]->tagData;
     $update_version = $update_config->document->latestversion[0]->tagData;
     if ($update_version > $module_version) {
         return true;
     }
     return false;
 }
Esempio n. 2
0
<?php

global $zdbh;
$modsql = $zdbh->prepare("SELECT * FROM x_modules ORDER BY mo_name_vc ASC");
$modsql->execute();
echo fs_filehandler::NewLine() . "START checking for any avaliable module updates.." . fs_filehandler::NewLine();
while ($modules = $modsql->fetch()) {
    echo "Checking update for mod: " . $modules['mo_name_vc'] . fs_filehandler::NewLine();
    $mod_config = new xml_reader(fs_filehandler::ReadFileContents(ctrl_options::GetSystemOption('MADmin_root') . 'modules/' . $modules['mo_folder_vc'] . '/module.xml'));
    $mod_config->Parse();
    if (isset($mod_config->document->version[0]->tagData)) {
        $current_version = $mod_config->document->version[0]->tagData;
        $updateurl = $mod_config->document->updateurl[0]->tagData;
        $getupdateinfo = fs_filehandler::ReadFileContents($updateurl);
        if (strstr(strtoupper($getupdateinfo), 'LATESTVERSION')) {
            $updateinfo = new xml_reader($getupdateinfo);
            $updateinfo->Parse();
            if (isset($updateinfo->document->latestversion[0]->tagData)) {
                $latest_version = $updateinfo->document->latestversion[0]->tagData;
                $downloadurl = $updateinfo->document->downloadurl[0]->tagData;
                if ($current_version < $latest_version) {
                    $versionsql = $zdbh->prepare("UPDATE x_modules SET mo_updatever_vc = :latest_version, mo_updateurl_tx = :downloadurl WHERE mo_id_pk = :mo_id_pk");
                    $versionsql->bindParam(':mo_id_pk', $modules['mo_id_pk']);
                    $versionsql->bindParam(':latest_version', $latest_version);
                    $versionsql->bindParam(':downloadurl', $downloadurl);
                    $versionsql->execute();
                } else {
                    $versionsql = $zdbh->prepare("UPDATE x_modules SET mo_updatever_vc = '', mo_updateurl_tx = '' WHERE mo_id_pk = :mo_id_pk");
                    $versionsql->bindParam(':mo_id_pk', $modules['mo_id_pk']);
                    $versionsql->execute();
                }
Esempio n. 3
0
 static function getPackageSelection()
 {
     global $controller;
     $toReturn = "";
     $packages = new xml_reader(fs_filehandler::ReadFileContents("./modules/" . $controller->GetControllerRequest('URL', 'module') . "/packages/packages.xml"));
     $packages->Parse();
     $toReturn .= "\n\t\t(Sortable columns - click on column header)\n\t\t<table class=\"table table-striped sortable\" border=\"0\" width=\"100%\">\n\t\t  <tr>\n\t\t\t<th>" . ui_language::translate("Package") . "<br />\n\t\t\t" . ui_language::translate("Name") . "</th>\n\t\t\t<th>" . ui_language::translate("Version") . "<br />\n\t\t\t" . ui_language::translate("Number") . "</th>\n\t\t\t<th>" . ui_language::translate("Package") . "<br />\n\t\t\t" . ui_language::translate("Type") . "</th>\n\t\t\t<th>" . ui_language::translate("Package") . "<br />\n\t\t\t" . ui_language::translate("Description") . "</th>\n\t\t\t<th>" . ui_language::translate("Database") . "<br />\n\t\t\t" . ui_language::translate("Required") . "?</th>\n\t\t\t<th>&nbsp;</th>\n\t\t  </tr>";
     foreach ($packages->document->package as $package) {
         // START - Info and DB tags by tgates
         if ($package->db[0]->tagData == 'yes') {
             $package->pkgdb[0]->tagData = "yes";
         } else {
             $package->pkgdb[0]->tagData = "no";
         }
         if ($package->db[0]->tagData == 'yes') {
             $package->db[0]->tagData = "<font color='green'><strong>" . ui_language::translate("YES") . "</strong></font>";
         } else {
             $package->db[0]->tagData = "<font color='red'><strong>" . ui_language::translate("NO") . "</strong></font>";
         }
         // END - Info and DB tags by tgates
         $toReturn .= "<tr>\n\t\t\t<td>" . $package->name[0]->tagData . "</td>\n\t\t\t<td>" . $package->version[0]->tagData . "</td>\n\t\t\t<td>" . $package->type[0]->tagData . "</td>\n\t\t\t<td>" . $package->info[0]->tagData . "</td>\n\t\t\t<td><center>" . $package->db[0]->tagData . "</center></td>\n\t\t\t<td>\n\t\t\t\t<form id=\"install\" name=\"Install\" action=\"/?module=sentastico\" method=\"post\">\n\t\t\t\t<input type=\"hidden\" name=\"startinstall\" value=\"true\"> \n\t\t\t\t<input type=\"hidden\" name=\"pkgzip\" value=" . $package->zipname[0]->tagData . "> \n\t\t\t\t<input type=\"hidden\" name=\"pkg\" value='" . $package->name[0]->tagData . "'> \n\t\t\t\t<input type=\"hidden\" name=\"pkgdb\" value=" . $package->pkgdb[0]->tagData . "> \n\t\t\t\t<input class=\"btn btn-primary btn-small\" type=\"submit\" name=\"doInstall\" value=" . ui_language::translate("Install") . " />\n\t\t\t\t</form>\n\t\t\t</td>\n\t\t</tr>";
     }
     return $toReturn;
 }
Esempio n. 4
0
 static function getCustomPackageSelection()
 {
     global $controller;
     $toReturn = "";
     if (file_exists("./modules/" . $controller->GetControllerRequest('URL', 'module') . "/packages/custom_packages.xml")) {
         $packages = new xml_reader(fs_filehandler::ReadFileContents("./modules/" . $controller->GetControllerRequest('URL', 'module') . "/packages/custom_packages.xml"));
         $packages->Parse();
         foreach ($packages->document->package as $package) {
             // START - Info and DB tags by tgates
             if ($package->db[0]->tagData == 'yes') {
                 $package->pkgdb[0]->tagData = "yes";
             } else {
                 $package->pkgdb[0]->tagData = "no";
             }
             if ($package->db[0]->tagData == 'yes') {
                 $package->db[0]->tagData = "<font color='green'><strong>" . ui_language::translate("YES") . "</strong></font>";
             } else {
                 $package->db[0]->tagData = "<font color='red'><strong>" . ui_language::translate("NO") . "</strong></font>";
             }
             // END - Info and DB tags by tgates
             $toReturn .= "<tr>\n\t\t\t<td>" . $package->name[0]->tagData . "</td>\n\t\t\t<td>" . $package->version[0]->tagData . "</td>\n\t\t\t<td>" . $package->type[0]->tagData . "</td>\n\t\t\t<td>" . $package->info[0]->tagData . "</td>\n\t\t\t<td><center>" . $package->db[0]->tagData . "</center></td>\n\t\t\t<td>\n\t\t\t\t<form id=\"install\" name=\"Install\" action=\"/?module=sentastico\" method=\"post\">\n\t\t\t\t<input type=\"hidden\" name=\"startinstall\" value=\"true\"> \n\t\t\t\t<input type=\"hidden\" name=\"pkgzip\" value=" . $package->zipname[0]->tagData . "> \n\t\t\t\t<input type=\"hidden\" name=\"pkg\" value='" . $package->name[0]->tagData . "'> \n\t\t\t\t<input type=\"hidden\" name=\"pkgdb\" value=" . $package->pkgdb[0]->tagData . "> \n\t\t\t\t<input class=\"btn btn-primary btn-small\" type=\"submit\" name=\"doInstall\" value=" . ui_language::translate("Install") . " />\n\t\t\t\t</form>\n\t\t\t</td>\n\t\t</tr>";
         }
         $toReturn .= "</table><br />";
     } else {
         $toReturn .= "</table><br />";
     }
     //$toReturn .= "</form>";
     return $toReturn;
 }
Esempio n. 5
0
 /**
  * Returns an array of the XML tags from the module.xml file.
  * @author Bobby Allen (ballen@bobbyallen.me)
  * @global obj $zlo The Generic ZPX logging object.
  * @param string $modulefolder The module folder name of which to import the XML data from.
  * @return mixed Will an array of the module XML data if the parsing of the document is successful otherwise will return 'false'.
  */
 static function GetModuleXMLTags($modulefolder)
 {
     global $zlo;
     $mod_xml = "modules/{$modulefolder}/module.xml";
     $info = array();
     try {
         $mod_config = new xml_reader(fs_filehandler::ReadFileContents($mod_xml));
         $mod_config->Parse();
         $info['name'] = $mod_config->document->name[0]->tagData;
         $info['version'] = $mod_config->document->version[0]->tagData;
         $info['desc'] = $mod_config->document->desc[0]->tagData;
         $info['authorname'] = $mod_config->document->authorname[0]->tagData;
         $info['authoremail'] = $mod_config->document->authoremail[0]->tagData;
         $info['authorurl'] = $mod_config->document->authorurl[0]->tagData;
         $info['updateurl'] = $mod_config->document->updateurl[0]->tagData;
         return $info;
     } catch (Exception $e) {
         return false;
     }
 }
 /**
  * Builds database schema from the module XML file (dbs.xml)
  * @author Russell Skinner (rustus@sentora.org)
  * @global db_driver $zdbh The ZPX database handle.
  */
 static function moduledb_commit()
 {
     global $zdbh;
     $mod_db_dir = ctrl_options::GetSystemOption('sentora_root') . "modules/*/{dbs.xml}";
     try {
         foreach (glob($mod_db_dir, GLOB_BRACE) as $mod_db_file) {
             $db_config = new xml_reader(fs_filehandler::ReadFileContents($mod_db_file));
             $db_config->Parse();
             $database = $db_config->document->database[0]->tagData;
             $sql = $zdbh->prepare("CREATE DATABASE IF NOT EXISTS {$database}");
             $sql->execute();
             foreach ($db_config->document->table_structure as $table) {
                 $table_name = $table->table_name[0]->tagData;
                 // Check if table exists, if not then create it.
                 $sql = $zdbh->prepare("SHOW TABLES FROM {$database} LIKE '{$table_name}'");
                 $sql->execute();
                 $table_exists = $sql->fetch();
                 if (!$table_exists) {
                     $sql = $zdbh->prepare("CREATE TABLE {$database}.{$table_name} (create_temp INT)");
                     $sql->execute();
                 }
                 // Loop through columnns for selected table
                 foreach ($table->column as $data) {
                     $column_name = $data->column_name[0]->tagData;
                     $column_structure = $data->column_structure[0]->tagData;
                     $sql = $zdbh->prepare("SHOW COLUMNS FROM {$database}.{$table_name} LIKE '{$column_name}'");
                     $sql->execute();
                     $column_exists = $sql->fetch();
                     if (!$column_exists) {
                         $sql = $zdbh->prepare("ALTER TABLE {$database}.{$table_name} ADD {$column_name} {$column_structure}");
                         $sql->execute();
                     }
                 }
                 // Populate tables with data from xml
                 $sql = $zdbh->prepare("SELECT COUNT(*) FROM {$database}.{$table_name}");
                 $sql->execute();
                 $empty = $sql->fetch();
                 if ($empty[0] == 0) {
                     // Loop through inserts/updates for selected table
                     foreach ($table->data as $data) {
                         if (!empty($data->insert[0])) {
                             $insert = $data->insert[0]->tagData;
                             $sql = $zdbh->prepare("INSERT INTO {$database}.{$table_name} {$insert}");
                             $sql->execute();
                         }
                         if (!empty($data->update[0])) {
                             $update = $data->update[0]->tagData;
                             $sql = $zdbh->prepare("UPDATE {$database}.{$table_name} SET {$update}");
                             $sql->execute();
                         }
                     }
                 }
                 // Remove temp table if created.
                 $sql = $zdbh->prepare("SHOW COLUMNS FROM {$database}.{$table_name} LIKE 'create_temp'");
                 $sql->execute();
                 $table_exists = $sql->fetch();
                 if ($table_exists) {
                     $sql = $zdbh->prepare("ALTER TABLE {$database}.{$table_name} DROP create_temp");
                     $sql->execute();
                 }
             }
         }
     } catch (Exception $e) {
         echo ui_sysmessage::shout($e, 'zdebug', 'zdebug');
     }
     return;
 }