function load()
 {
     global $config;
     if ($this->exists() == true) {
         $this->import();
     } else {
         global $config, $admconfig;
         $this->data = array();
         $myini = new INI();
         $servers = explode(';', $admconfig['package_server']);
         if (is_array($servers)) {
             foreach ($servers as $server) {
                 $content = get_remote($server . '/external.ini');
                 if ($content != REMOTE_CLIENT_ERROR) {
                     $inis = $myini->parse($content);
                     if (!isset($inis['files'])) {
                         break;
                     }
                     foreach ($inis['files'] as $type => $remotefile) {
                         if (!isset($this->data[$type])) {
                             $this->data[$type] = array();
                         }
                         if (empty($remotefile)) {
                             continue;
                         }
                         $path = $server . '/' . $remotefile;
                         $content = get_remote($path);
                         if ($content != REMOTE_CLIENT_ERROR) {
                             $new_data = $myini->parse($content);
                             if (!isset($new_data['categories'])) {
                                 continue;
                             }
                             foreach ($new_data['categories'] as $cid => $cname) {
                                 $this->data[$type]['categories'][$cid] = array('name' => $cname, 'entries' => 0);
                                 $this->data[$type][$cid] = array();
                             }
                             foreach ($new_data as $key => $row) {
                                 if ($key == 'categories') {
                                     continue;
                                 } else {
                                     if (!isset($row['category']) || !isset($this->data[$type]['categories'][$row['category']])) {
                                         continue;
                                     }
                                     if (isset($this->data[$type][$row['internal']]) && version_compare($this->data[$type][$this->data[$type][$row['internal']]][$row['internal']]['version'], $row['version'], ">") || !isset($this->data[$type][$row['internal']])) {
                                         $row['server'] = $server;
                                         $this->data[$type]['categories'][$row['category']]['entries']++;
                                         $this->data[$type][$row['category']][$row['internal']] = $row;
                                         $this->data[$type][$row['internal']] = $row['category'];
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         $this->export();
     }
 }
Example #2
0
    $dirs = glob("*", GLOB_ONLYDIR);
    foreach ($dirs as $key2 => $dir2) {
        chdir($dir2);
        $files[$key2 + 1] = array_merge(glob("*.zip"), glob("*.bbc"));
        $ini['categories'][$key2 + 1] = $dir2;
        chdir("../");
    }
    chdir($cwd);
    foreach ($files as $dirid => $files2) {
        foreach ($files2 as $file) {
            $fp = 'viscacha/files/' . $dir . '/' . $ini['categories'][$dirid] . '/' . $file;
            $data = array('title' => $file, 'internal' => "viscacha_" . substr($file, 0, strlen($file) - 4), 'version' => "", 'copyright' => "Copyright (c) 2007 by Matthias Mohr, MaMo Net (http://www.mamo-net.de)", 'summary' => "", 'license' => "GNU General Public License", 'min_version' => "", 'max_version' => "", 'url' => "http://www.viscacha.org", 'file' => "http://files.viscacha.org/{$dir}/" . rawurlencode($ini['categories'][$dirid]) . "/{$file}", 'preview' => "", 'category' => $dirid, 'multiple' => 0, 'last_updated' => filemtime($fp));
            if ($key == IMPTYPE_PACKAGE) {
                $zip = new PclZip($fp);
                $list = $zip->extract(PCLZIP_OPT_BY_NAME, "modules/package.ini", PCLZIP_OPT_EXTRACT_AS_STRING);
                $package = $myini->parse($list[0]['content']);
                if (empty($package['info']['title']) || empty($package['info']['internal'])) {
                    continue;
                }
                $data = array_merge($data, $package['info']);
                unset($data['core']);
            }
            $md5 = md5_file($fp);
            $ini[$md5] = $data;
        }
    }
    $myini->write('viscacha/files/external_' . $key . '.ini', $ini);
    ?>
		<hr />
		Files generated: <a href="viscacha/files/external_<?php 
    echo $key;