Example #1
0
                continue;
            }
            $this->stdout->write(sprintf("%s (%s)\n", $code, $name));
        }
    }
    function _build($lang)
    {
        list($code, $zip) = $this->_request("download/{$lang}.zip");
        if ($code !== 200) {
            $this->fail('Language is not available' . "\n");
        }
        $temp = tempnam('/tmp', 'osticket-cli');
        $f = fopen($temp, 'w');
        fwrite($f, $zip);
        fclose($f);
        $zip = new ZipArchive();
        $zip->open($temp);
        unlink($temp);
        $lang = str_replace('-', '_', $lang);
        @unlink(I18N_DIR . "{$lang}.phar");
        $phar = new Phar(I18N_DIR . "{$lang}.phar");
        for ($i = 0; $i < $zip->numFiles; $i++) {
            $info = $zip->statIndex($i);
            $phar->addFromString($info['name'], $zip->getFromIndex($i));
        }
        // TODO: Add i18n extras (like fonts)
        // TODO: Sign files
    }
}
Module::register('i18n', 'i18n_Compiler');
Example #2
0
        static $header = null;
        static $rows = array();
        static $length = 0;
        if ($info && $header === null) {
            $header = "INSERT INTO `" . TABLE_PREFIX . $info[1] . '` (';
            $cols = array();
            foreach ($info[2] as $col) {
                $cols[] = "`{$col}`";
            }
            $header .= implode(', ', $cols);
            $header .= ") VALUES ";
        }
        if ($row) {
            $values = array();
            foreach ($info[2] as $i => $col) {
                $values[] = is_numeric($row[$i]) ? $row[$i] : ($row[$i] ? '0x' . bin2hex($row[$i]) : "''");
            }
            $values = "(" . implode(', ', $values) . ")";
            $length += strlen($values);
            $rows[] =& $values;
        }
        if (($flush || $length > 16000) && $header) {
            $this->send_statement($header . implode(',', $rows));
            $header = null;
            $rows = array();
            $length = 0;
        }
    }
}
Module::register('import', 'Importer');
Example #3
0
// --------------------------------------------------------------
View::composer('admin::layouts.default', function ($view) {
    $view->shares('url', prefix('admin') . '/');
    Asset::container('header')->add('jquery', 'js/jquery.min.js')->add('bootstrap', 'bootstrap/css/bootstrap.css')->add('main', 'html/layla.css');
    Asset::container('footer')->add('bootstrap', 'js/bootstrap.js');
});
// --------------------------------------------------------------
// Adding menu items
// --------------------------------------------------------------
Menu::handler('main')->add('home', 'Home', null, array('class' => 'icon-home'))->add('pages', 'Pages', null, array('class' => 'icon-pages'))->add('media', 'Media', null, array('class' => 'icon-media'))->add('accounts', 'Accounts', null, array('class' => 'icon-accounts'))->add('settings', 'Settings', null, array('class' => 'icon-settings'))->add('#', '', null, array('class' => 'logo'))->add('profile', 'Profile', null, array('class' => 'icon-profile'));
// --------------------------------------------------------------
// Registering forms and pages
// --------------------------------------------------------------
Module::register('page', 'account.read_multiple', 'admin::account@read_multiple');
Module::register('page', 'account.create', 'admin::account@create');
Module::register('form', 'account.create', 'admin::account@create');
Module::register('page', 'account.update', 'admin::account@update');
Module::register('form', 'account.update', 'admin::account@update');
Module::register('page', 'account.delete', 'admin::account@delete');
Module::register('form', 'account.delete', 'admin::account@delete');
Module::register('page', 'page.read_multiple', 'admin::page@read_multiple');
Module::register('page', 'page.create', 'admin::page@create');
Module::register('form', 'page.create', 'admin::page@create');
Module::register('page', 'page.update', 'admin::page@update');
Module::register('form', 'page.update', 'admin::page@update');
Module::register('page', 'page.delete', 'admin::page@delete');
Module::register('form', 'page.delete', 'admin::page@delete');
Module::register('page', 'media.read_multiple', 'admin::media@read_multiple');
Module::register('page', 'media.group.read_multiple', 'admin::media.group@read_multiple');
Module::register('page', 'media.group.asset.read_multiple', 'admin::media.group.asset@read_multiple');
Example #4
0
        if (!$zip->open($name, ZipArchive::CREATE | ZipArchive::OVERWRITE) === true) {
            return false;
        }
        $php56 = version_compare(phpversion(), '5.6.0', '>');
        $addFiles = function ($dir) use(&$addFiles, $zip, $path, $php56) {
            $files = array_diff(scandir($dir), array('.', '..'));
            $path = rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
            foreach ($files as $file) {
                $full = "{$dir}/{$file}";
                $local = str_replace($path, '', $full);
                if (is_dir($full)) {
                    $addFiles($full);
                } else {
                    // XXX: AddFile() will keep the file open and run
                    //      out of OS open file handles
                    $zip->addFromString($local, file_get_contents($full));
                }
                // This only works on PHP >= v5.6
                if ($php56) {
                    // Set the Unix mode of the file
                    $stat = stat($full);
                    $zip->setExternalAttributesName($local, ZipArchive::OPSYS_UNIX, $stat['mode']);
                }
            }
        };
        $addFiles($path);
        return $zip->close();
    }
}
Module::register('package', 'Packager');
Example #5
0
                    if ($name == 'min-size') {
                        $qs->filter(array('size__gte' => $val));
                    } else {
                        $qs->filter(array('size__lte' => $val));
                    }
                    break;
                case 'limit':
                    if (!is_numeric($val)) {
                        $this->fail('Provide an result count number to --limit');
                    }
                    $qs->limit($val);
                    break;
            }
        }
    }
}
require_once INCLUDE_DIR . 'class.orm.php';
class FileModel extends VerySimpleModel
{
    static $meta = array('table' => FILE_TABLE, 'pk' => 'id', 'joins' => array('tickets' => array('null' => true, 'constraint' => array('id' => 'TicketAttachmentModel.file_id'))));
}
class TicketAttachmentModel extends VerySimpleModel
{
    static $meta = array('table' => TICKET_ATTACHMENT_TABLE, 'pk' => 'attach_id', 'joins' => array('ticket' => array('null' => false, 'constraint' => array('ticket_id' => 'TicketModel.ticket_id'))));
}
class AttachmentModel extends VerySimpleModel
{
    static $meta = array('table' => ATTACHMENT_TABLE, 'pk' => array('object_id', 'type', 'file_id'));
}
Module::register('file', 'FileManager');
Example #6
0
        if ($exporter) {
            $this->dump($exporter);
        }
    }
    function dump($module)
    {
        $stream = $this->getOption('stream');
        if ($this->getOption('compress')) {
            $stream = "compress.zlib://{$stream}";
        }
        $stream = fopen($stream, 'w');
        $x = new $module($stream, $this->_options);
        $x->dump($this->stderr);
    }
    function showHelp()
    {
        $modules = array();
        foreach (glob(dirname(__FILE__) . '/importer/*.php') as $script) {
            $info = pathinfo($script);
            $modules[] = $info['filename'];
        }
        $this->epilog = "Currently available modules follow. Use 'manage.php export <module>\n            --help' for usage regarding each respective module:";
        parent::showHelp();
        echo "\n";
        foreach ($modules as $name) {
            echo str_pad($name, 20) . "\n";
        }
    }
}
Module::register('export', 'Exporter');
Example #7
0
        # Unpack the upload folder to the destination, except the include folder
        if ($upgrade)
            # Get the current value of the INCLUDE_DIR before overwriting
            # main.inc.php
            $include = $this->get_include_dir();
        $this->unpackage("$upload/{,.}*", $this->destination, -1, "*include");

        if (!$upgrade) {
            if ($this->getOption('include')) {
                $location = $this->getOption('include');
                if (!is_dir("$location/"))
                    if (!mkdir("$location/", 0751, true))
                        die("Unable to create folder for include/ files\n");
                $this->unpackage("$upload/include/{,.}*", $location, -1);
                $this->change_include_dir($location);
            }
            else
                $this->unpackage("$upload/include/{,.}*", "{$this->destination}/include", -1);
        }
        else {
            $this->unpackage("$upload/include/{,.}*", $include, -1);
            # Change the new main.inc.php to reflect the location of the
            # include/ directory
            $this->change_include_dir($include);
        }
    }
}

Module::register('unpack', 'Unpacker');
Example #8
0
                if ($options['org']) {
                    if (!($org = Organization::lookup($options['org']))) {
                        $this->fail($options['org'] . ': Unknown organization ID');
                    }
                    $extras['org_id'] = $options['org'];
                }
                $status = User::importCsv($this->stream, $extras);
                if (is_numeric($status)) {
                    $this->stderr->write("Successfully imported {$status} clients\n");
                } else {
                    $this->fail($status);
                }
                break;
            case 'export':
                $stream = $options['file'] ?: 'php://stdout';
                if (!($this->stream = fopen($stream, 'c'))) {
                    $this->fail("Unable to open output file [{$options['file']}]");
                }
                fputcsv($this->stream, array('Name', 'Email'));
                foreach (User::objects() as $user) {
                    fputcsv($this->stream, array((string) $user->getName(), $user->getEmail()));
                }
                break;
            default:
                $this->stderr->write('Unknown action!');
        }
        @fclose($this->stream);
    }
}
Module::register('user', 'UserManager');
Example #9
0
                    }
                    // TODO: process the header here to figure out the columns
                    // for now we're assuming one column of Name
                }
                while (($data = fgetcsv($this->stream, 1000, ",")) !== FALSE) {
                    if (!$data[0]) {
                        $this->stderr->write('Invalid data format: Name
                                required');
                    } elseif (!Organization::fromVars(array('name' => $data[0], 'email'))) {
                        $this->stderr->write('Unable to import record: ' . print_r($data, true));
                    }
                }
                break;
            case 'export':
                $stream = $options['file'] ?: 'php://stdout';
                if (!($this->stream = fopen($stream, 'c'))) {
                    $this->fail("Unable to open output file [{$options['file']}]");
                }
                fputcsv($this->stream, array('Name'));
                foreach (Organization::objects() as $org) {
                    fputcsv($this->stream, array((string) $org->getName()));
                }
                break;
            default:
                $this->stderr->write('Unknown action!');
        }
        @fclose($this->stream);
    }
}
Module::register('org', 'OrganizationManager');
Example #10
0
    The main() containing class MUST be loaded in "filesLoadTime".
*/
Module::register(array('class' => 'IndcPage', 'filesRunTime' => array(), 'filesLoadTime' => array('inducements/class_inducements.php')));
Module::register(array('class' => 'PDFroster', 'filesRunTime' => array('pdf/bb_pdf_class.php'), 'filesLoadTime' => array('pdf/pdf_roster.php')));
Module::register(array('class' => 'RSSfeed', 'filesRunTime' => array(), 'filesLoadTime' => array('rss/class_rss.php')));
Module::register(array('class' => 'SGraph', 'filesRunTime' => array(), 'filesLoadTime' => array('statsgraph/header.php', 'statsgraph/class_statsgraph.php')));
Module::register(array('class' => 'Memmatches', 'filesRunTime' => array(), 'filesLoadTime' => array('memmatches/class_memmatches.php')));
Module::register(array('class' => 'Wanted', 'filesRunTime' => array(), 'filesLoadTime' => array('wanted/class_wanted.php')));
Module::register(array('class' => 'HOF', 'filesRunTime' => array(), 'filesLoadTime' => array('halloffame/class_hof.php')));
Module::register(array('class' => 'Prize', 'filesRunTime' => array(), 'filesLoadTime' => array('prizes/header.php', 'prizes/class_prize.php')));
Module::register(array('class' => 'UPLOAD_BOTOCS', 'filesRunTime' => array('leegmgr/class_match_botocs.php'), 'filesLoadTime' => array('leegmgr/class_upload_botocs.php')));
Module::register(array('class' => 'XML_BOTOCS', 'filesRunTime' => array(), 'filesLoadTime' => array('leegmgr/class_xml_botocs.php')));
Module::register(array('class' => 'Registration', 'filesRunTime' => array(), 'filesLoadTime' => array('registration/class_registration.php')));
Module::register(array('class' => 'LogSubSys', 'filesRunTime' => array(), 'filesLoadTime' => array('log/class_log.php', 'log/header.php')));
Module::register(array('class' => 'Gallery', 'filesRunTime' => array(), 'filesLoadTime' => array('gallery/class_gallery.php')));
Module::register(array('class' => 'Search', 'filesRunTime' => array(), 'filesLoadTime' => array('search/class_search.php')));
Module::register(array('class' => 'PDFMatchReport', 'filesRunTime' => array(), 'filesLoadTime' => array('pdfmatchreport/class_pdfmatchreport.php')));
Module::register(array('class' => 'LeagueTables', 'filesRunTime' => array(), 'filesLoadTime' => array('leaguetables/class_leaguetables.php')));
Module::register(array('class' => 'Conference', 'filesRunTime' => array(), 'filesLoadTime' => array('conference/class_conference.php')));
Module::register(array('class' => 'TeamCompare', 'filesRunTime' => array(), 'filesLoadTime' => array('teamcompare/class_teamcompare.php')));
/*Module::register(array(
    'class'         => 'Adverts',
    'filesRunTime'  => array(),
    'filesLoadTime' => array('adverts/class_adverts.php')
));*/
Module::register(array('class' => 'LeaguePref', 'filesRunTime' => array(), 'filesLoadTime' => array('leaguePref/class_league_pref.php')));
Module::register(array('class' => 'TeamCreator', 'filesRunTime' => array(), 'filesLoadTime' => array('teamcreator/class_team_creator.php')));
Module::register(array('class' => 'Scheduler', 'filesRunTime' => array(), 'filesLoadTime' => array('scheduler/class_scheduler.php')));
Module::register(array('class' => 'Cemetery', 'filesRunTime' => array(), 'filesLoadTime' => array('cemetery/class_cemetery.php')));
Module::register(array('class' => 'FamousTeams', 'filesRunTime' => array(), 'filesLoadTime' => array('famousteams/class_famousteams.php')));
Example #11
0
            "*.sw[a-z]","*.md", "*.txt");
        if (!$options['setup'])
            $exclusions[] = "$rootPattern/setup/*";

        # Unpack everything but the include/ folder
        $this->unpackage("$root/{,.}*", $this->destination, -1,
            $exclusions);
        # Unpack the include folder
        $this->unpackage("$root/include/{,.}*", $include, -1,
            array("*/include/ost-config.php"));
        if (!$options['dry-run']) {
            if ($include != "{$this->destination}/include/")
                $this->change_include_dir($include);
        }

        if ($options['clean']) {
            // Clean everything but include folder first
            $this->clean($root, $this->destination, -1,
                array($include, "setup/"));
            $this->clean("$root/include", $include, -1,
                array("ost-config.php","settings.php","plugins/",
                "*/.htaccess"));
        }

        $this->writeManifest($this->destination);
    }
}

Module::register('deploy', 'Deployment');
?>