<?php function output($method, $data) { $serverid = (int) $_GET['serverid']; if (!isset($_GET['plain'])) { echo 'update.' . $method . '(' . intval($serverid) . ', ' . json_encode($data) . ");\n"; } else { echo json_encode($data); } } try { if (!empty($_GET['package'])) { $data = db()->update_package->get("id = '%s'", $_GET['package'])->assoc(); $pkg = new update_package($data); $current = intval($_GET['current']); output('install', $pkg->deliver($_SERVER['REMOTE_ADDR'], $current)); $col = $current ? 'updates' : 'installations'; db()->query("UPDATE update_package SET %s = %s + 1 WHERE id = '%s'", $col, $col, $data['id']); } else { output('remote', array_values(update_package::liste($_SERVER['REMOTE_ADDR']))); } } catch (Exception $e) { output('error', array('error' => $e->getMessage())); }
<?php $packages = update_package::liste(); $sources = db()->query('SELECT * FROM update_server')->assocs('id'); if (file_exists('inc/ftp.config.php')) { require_once 'inc/ftp.config.php'; $writer = new writer_ftp($ftp_host, $ftp_user, $ftp_pass, $ftp_dir); } else { $writer = new writer_fs(); } if (!empty($_GET['edit'])) { if (empty($packages[$_GET['edit']])) { throw new Exception('Paket nicht gefunden!'); } new update_manager($view, $packages[$_GET['edit']]); } elseif (isset($_GET['storefile'])) { $view->format = 'plain'; $pkg = new update_package(array('id' => $_POST['pkg'])); $pkg->updateFile($_POST['path'], $_POST['content']); $view->content('ok'); } elseif (isset($_GET['addpackage'])) { $view->format = 'plain'; $pkg = new update_package($_POST); $pkg->install($writer); $view->content('ok'); } elseif (isset($_GET['getmigrations'])) { $all = globFiles('migration/*'); $applied = db()->select('update_migration')->assocs('id'); $result = $pending = array(); foreach ($all as $id) { if (empty($applied[$id])) {