static function form($folder, $required_fields) { setup::out_exit(' Folder: ' . q(modify::getpathfull($folder)) . '<br> <br> <a href="index.php?export=calc&limit=1&hide_fields=id&folder=' . q($folder) . '&view=details">{t}Download example file{/t} (.xls)</a> <br> {t}Required fields{/t}: ' . q(implode(", ", $required_fields)) . ' <br><br> {t}File{/t} (.xls):<br> <form method="post" action="import.php?" enctype="multipart/form-data"> <input type="hidden" name="token" value="' . modify::get_form_token() . '"> <input type="hidden" name="folder" value="' . q($folder) . '"> <input type="File" name="file[]" value="" multiple="true" required="true"> <input type="submit" value="{t}I m p o r t{/t}" class="submit"> <input type="submit" name="validate_only" value="{t}V a l i d a t e{/t}" class="submit"> </form> <br> <b>{t}Note{/t}:</b> {t}Assets can be imported into multiple folders by adding the "Folder" column.{/t}<br> <b>{t}Note{/t}:</b> {t}Assets can be overwritten by adding the "Id" column.{/t}<br> <br> <div style="border-top: 1px solid black;">Powered by Simple Groupware, Copyright (C) 2002-2012 by Thomas Bley.</div></div> </body> </html> '); }
@set_time_limit(1800); if (!sys_is_super_admin($_SESSION["username"])) { sys_die(t("{t}Not allowed. Please log in as super administrator.{/t}")); } updater::header(); $mirror_id = "sourceforge"; if (!empty($_REQUEST["mirror"]) and in_array($_REQUEST["mirror"], array_keys(updater::$mirrors))) { $mirror_id = $_REQUEST["mirror"]; } $mirror = updater::$mirrors[$mirror_id]; $move_folders = array("build/", "core/", "docs/", "ext/", "import/", "lang/", "lib/", "templates/", "tools/", "modules/"); sys_mkdir(SIMPLE_STORE . "/old/"); $folders = array_merge(array("./", SIMPLE_STORE . "/old/"), $move_folders); foreach ($folders as $folder) { if (is_dir($folder) and !is_writable($folder)) { setup::out_exit(t("{t}Please give write access to %s{/t}", $folder)); } } if (empty($_REQUEST["release"]) and empty($_REQUEST["cfile"]) or !sys_validate_token()) { updater::show_list($mirror_id); } else { if (!empty($_REQUEST["cfile"])) { $source = $_REQUEST["cfile"]; if (!file_exists($source) or filesize($source) < 3 * 1048576) { sys_die(t("{t}Error{/t}") . ": file-check [0] " . $source); } } else { $release = $_REQUEST["release"]; if ($release == "latest" or !is_numeric($release)) { $data = @file_get_contents($mirror["url"]); $match = array();
static function show_list($mirror_id) { setup::out("\n\t<div style='color:#ff0000;'>\n\t<b>{t}Warning{/t}</b>:<br>\n\t- Please make a complete backup of your database (e.g. using phpMyAdmin)<br>\n\t- Please make a complete backup of your sgs folder (e.g. /var/www/htdocs/sgs/)<br>\n\t- Make sure both backups are complete!\n </div>\n\t<br>\n\t{t}Downloading update list{/t} ...<br>\n "); $mirror = self::$mirrors[$mirror_id]; $ctx = stream_context_create(array("http" => array("timeout" => 5))); $data = @file_get_contents($mirror["url"], 0, $ctx); $match = array(); preg_match_all($mirror["pattern"], $data, $match); if (!empty($match[1]) and $data != "") { $found = false; foreach ($match[1] as $key => $item) { if ($key > 4) { break; } if (strpos("@" . $item, CORE_VERSION_STRING) and !DEBUG) { break; } if (!empty($match[3][$key]) and strtotime($match[3][$key]) + 3600 > time()) { continue; } $found = true; $check = true; if (!empty($match[2][$key])) { $match_version = array(); preg_match("/php (\\d+\\.\\d+\\.\\d+)/i", $match[2][$key], $match_version); if (!empty($match_version[1]) and version_compare(PHP_VERSION, $match_version[1], "<")) { setup::out(sprintf("{t}Setup needs php with at least version %s !{/t}", $match_version[1])); $check = false; } preg_match("/" . SETUP_DB_TYPE . " (\\d+\\.\\d+\\.\\d+)/i", $match[2][$key], $match_version); if (!empty($match_version[1])) { $db_version = str_replace(".", "", $match_version[1]); $curr_version = sgsml_parser::sql_version(); if ($curr_version < $db_version) { setup::out(sprintf("{t}Wrong database-version (%s). Please use at least %s !{/t}", $curr_version, $match_version[1])); $check = false; } } } if ($check) { setup::out("<a href='updater.php?mirror=" . $mirror_id . "&token=" . modify::get_form_token() . "&release=" . $item . "'>{t}I n s t a l l{/t}</a> Simple Groupware ", false); setup::out($item . " (<a target='_blank' href='http://www.simple-groupware.de/cms/Release-" . str_replace(".", "-", $item) . "'>Changelog</a>)<br>"); } } if (!$found) { setup::out("{t}Already running latest release.{/t}<br>"); } } else { setup::out(sprintf("{t}Connection error: %s [%s]{/t}", $mirror["url"], "HTTP") . "<br>" . strip_tags($data, "<br><p><h1><center>")); } setup::out("{t}Server{/t}: <b>" . $mirror["name"] . "</b>, {t}use mirror from{/t}: ", false); foreach (self::$mirrors as $key => $sel_mirror) { if ($key == $mirror_id) { continue; } setup::out("<a href='updater.php?mirror=" . $key . "'>" . $sel_mirror["name"] . "</a> "); } setup::out("<br/>{t}Package from local file system (.tar.gz){/t}:<br/>{t}current path{/t}: " . str_replace("\\", "/", getcwd()) . "/<br/>"); foreach (scandir("./") as $file) { if ($file[0] == "." or !preg_match("|^SimpleGroupware\\_.*?.tar\\.gz\$|i", $file)) { continue; } setup::out("<a href='updater.php?token=" . modify::get_form_token() . "&cfile=" . $file . "'>{t}I n s t a l l{/t}</a> " . $file . "<br/>"); } setup::out("<form method='POST'><input type='hidden' name='token' value='" . modify::get_form_token() . "'><input type='text' name='cfile' value='/tmp/SimpleGroupware_0.xyz.tar.gz' style='width:300px;'> <input type='submit' class='submit' value='{t}I n s t a l l{/t}'><br>"); setup::out("<input type='checkbox' name='nobackup' value='1' onchange='change_links(this.checked);'/> " . sprintf("{t}Don't move old files to '%s'{/t}", SIMPLE_STORE . "/old/") . "</form>"); setup::out_exit('<div style="border-top: 1px solid black;">Powered by Simple Groupware, Copyright (C) 2002-2012 by Thomas Bley.</div></div></body></html>'); }
static function showlist() { setup::out("\n\t<div style='color:#ff0000;'>\n\t<b>{t}Warning{/t}</b>:<br>\n\t- Please make a complete backup of your database (e.g. using phpMyAdmin)<br>\n\t- Please make a complete backup of your sgs folder (e.g. /var/www/htdocs/sgs/)<br>\n\t- Make sure both backups are complete!\n </div>\n "); setup::out("{t}Downloading extension list{/t} ...<br>"); $url = "http://sourceforge.net/projects/simplgroup/files/simplegroupware_modules/modules.xml"; if (!($data = sys_cache_get("modules.xml"))) { $data = @file_get_contents($url); sys_cache_set("modules.xml", $data, 3600); } if ($xml = @simplexml_load_string($data)) { foreach ($xml as $package) { $php_version = (string) $package->php_version; $sgs_version = (string) $package->require_version; $target = SIMPLE_EXT . substr(basename($package->filename), 0, -3); if (file_exists($target)) { continue; } $id = md5($package->filename); if (version_compare(PHP_VERSION, $php_version, "<")) { setup::out(sprintf("{t}Setup needs php with at least version %s !{/t} ", $php_version), false); } else { if (version_compare(CORE_VERSION_STRING, $sgs_version, "<")) { setup::out(sprintf("{t}Setup needs Simple Groupware with at least version %s !{/t} ", $sgs_version), false); } else { setup::out("<a href='extensions.php?token=" . modify::get_form_token() . "&extension=" . $package->name . "&filename=" . $package->filename . "'>{t}I n s t a l l{/t}</a> ", false); } } setup::out($package->title . " <a href='#' onclick='return showhide(\"" . $id . "\")'>{t}Info{/t}</a>", false); setup::out("<br><div class='description' style='display:none;' id='" . $id . "'>" . nl2br(trim($package->description)) . "</div>"); } } else { setup::out(sprintf("{t}Connection error: %s [%s]{/t}", $url, "HTTP") . "<br>" . strip_tags($data, "<br><p><h1><center>")); } setup::out("{t}Package from local file system (.tar.gz){/t}:<br/>{t}current path{/t}: " . str_replace("\\", "/", getcwd()) . "/<br/>"); $dir = opendir("./"); while ($file = readdir($dir)) { if ($file != "." and $file != ".." and preg_match("|^SimpleGroupware\\_.*?.tar\\.gz\$|i", $file)) { setup::out("<a href='extensions.php?token=" . modify::get_form_token() . "&cfile=" . $file . "'>{t}I n s t a l l{/t}</a> " . $file . "<br/>"); } } closedir($dir); setup::out("<form method='POST'><input type='hidden' name='token' value='" . modify::get_form_token() . "'><input type='text' name='cfile' value='/tmp/SimpleGroupware_SomeExtension_0.x.tar.gz' style='width:300px;'> <input type='submit' class='submit' value='{t}I n s t a l l{/t}'><br>"); $can_uninstall = false; foreach (scandir(SIMPLE_EXT) as $file) { if ($file[0] == "." or !is_dir(SIMPLE_EXT . $file) or !file_exists(SIMPLE_EXT . $file . "/package.xml")) { continue; } $package = simplexml_load_file(SIMPLE_EXT . $file . "/package.xml"); $id = md5($package->filename); setup::out("<a onclick='if (!confirm(\"{t}Really uninstall the module ?{/t}\")) return false;' href='extensions.php?token=" . modify::get_form_token() . "&uninstall=" . $package->filename . "'>{t}U n i n s t a l l{/t}</a> " . $package->title, false); setup::out(" <a href='#' onclick='return showhide(\"" . $id . "\")'>{t}Info{/t}</a>", false); setup::out(" ({t}installed{/t} " . sys_date("{t}m/d/Y{/t}", filemtime(SIMPLE_EXT . $file)) . ")"); setup::out("<div class='description' style='display:none;' id='" . $id . "'>" . nl2br(trim($package->description)) . "</div>"); $can_uninstall = true; } if ($can_uninstall) { setup::out("<b>{t}Note{/t}:</b> {t}Uninstall does not delete any data in the database.{/t}<br>"); } setup::out_exit('<div style="border-top: 1px solid black;">Powered by Simple Groupware, Copyright (C) 2002-2012 by Thomas Bley.</div></div></body></html>'); }