Example #1
0
 static function move_files($move_folders, $source_folder)
 {
     setup::out(sprintf("{t}Processing %s ...{/t}", "{t}Folders{/t}"));
     foreach ($move_folders as $folder) {
         if (!is_dir($folder)) {
             continue;
         }
         if (!empty($_REQUEST["nobackup"])) {
             dirs_delete_all($folder);
         } else {
             if (!file_exists(SIMPLE_STORE . "/old/" . rtrim($folder, "/") . "_" . CORE_VERSION . "/")) {
                 rename($folder, SIMPLE_STORE . "/old/" . rtrim($folder, "/") . "_" . CORE_VERSION . "/");
             }
         }
     }
     if (is_dir("core/")) {
         sys_die("{t}Error{/t}: rename [4]");
     }
     foreach (scandir($source_folder) as $folder) {
         if ($folder[0] != "." and is_dir($source_folder . $folder) and !is_dir($folder)) {
             rename($source_folder . $folder, $folder);
         }
     }
     if (!is_dir("core/")) {
         sys_die("{t}Error{/t}: rename [5]");
     }
     dirs_delete_all($source_folder);
     setup::out(sprintf("{t}Processing %s ...{/t}", "config.php"));
     rename("simple_store/config.php", "simple_store/config_old.php");
 }
Example #2
0
 static function save_config($vars)
 {
     $out = array();
     $out[] = "<?" . "php";
     $out[] = "define('CORE_VERSION','" . CORE_VERSION . "');";
     $out[] = "define('CORE_VERSION_STRING','" . CORE_VERSION_STRING . "');";
     $out[] = "define('CORE_SGSML_VERSION','" . CORE_SGSML_VERSION . "');";
     foreach ($vars as $key => $var) {
         $out[] = "define('" . $key . "'," . $var . ");";
     }
     foreach (self::config_defaults() as $key => $var) {
         $var = setup_update::get_config_old($key, true, $var);
         $out[] = "define('" . $key . "'," . $var . ");";
     }
     $out[] = "if (TIMEZONE!='') date_default_timezone_set(TIMEZONE);\n" . "  elseif (!ini_get('date.timezone')) date_default_timezone_set(@date_default_timezone_get());";
     $out[] = "if (!ini_get('display_errors')) @ini_set('display_errors','1');";
     $out[] = "define('NOW',time());";
     $out[] = "define('LANG','" . LANG . "');";
     $out[] = "define('APC',function_exists('apc_store') and ini_get('apc.enabled'));";
     file_put_contents("simple_store/config.php", implode("\n", $out), LOCK_EX);
     if (!file_exists("simple_store/config.php") or filesize("simple_store/config.php") == 0) {
         sys_die("cannot write to: simple_store/config.php");
     }
     chmod("simple_store/config.php", 0600);
     sys_log_message_log("info", sprintf("{t}Setup: setup-data written to %s.{/t}", "simple_store/config.php"));
 }
 static function install($source, $filename)
 {
     $target = SIMPLE_EXT . substr($filename, 0, -3);
     setup::out("{t}Download{/t}: " . $source . " ...");
     if ($fz = gzopen($source, "r") and $fp = fopen($target, "w")) {
         $i = 0;
         while (!gzeof($fz)) {
             $i++;
             setup::out(".", false);
             if ($i % 160 == 0) {
                 setup::out();
             }
             fwrite($fp, gzread($fz, 16384));
         }
         gzclose($fz);
         fclose($fp);
     } else {
         sys_die("{t}Error{/t}: gzopen [2] " . $source);
     }
     setup::out();
     if (!file_exists($target) or filesize($target) == 0 or filesize($target) % 10240 != 0) {
         sys_die("{t}Error{/t}: file-check [3] Filesize: " . filesize($target) . " " . $target);
     }
     setup::out(sprintf("{t}Processing %s ...{/t}", basename($target)));
     $tar_object = new Archive_Tar($target);
     $tar_object->setErrorHandling(PEAR_ERROR_PRINT);
     $tar_object->extract(SIMPLE_EXT);
     $file_list = $tar_object->ListContent();
     if (!is_array($file_list) or !isset($file_list[0]["filename"]) or !is_dir(SIMPLE_EXT . $file_list[0]["filename"])) {
         sys_die("{t}Error{/t}: tar [4] " . $target);
     }
     self::update_modules_list();
     $ext_folder = db_select_value("simple_sys_tree", "id", "anchor=@anchor@", array("anchor" => "extensions"));
     foreach ($file_list as $file) {
         sys_chmod(SIMPLE_EXT . $file["filename"]);
         setup::out(sprintf("{t}Processing %s ...{/t}", SIMPLE_EXT . $file["filename"]));
         if (basename($file["filename"]) == "install.php") {
             setup::out("");
             require SIMPLE_EXT . $file["filename"];
             setup::out("");
         }
         if (basename($file["filename"]) == "readme.txt") {
             $data = file_get_contents(SIMPLE_EXT . $file["filename"]);
             setup::out(nl2br("\n" . q($data) . "\n"));
         }
         if (!empty($ext_folder) and basename($file["filename"]) == "folders.xml") {
             setup::out(sprintf("{t}Processing %s ...{/t}", "folder structure"));
             folders::create_default_folders(SIMPLE_EXT . $file["filename"], $ext_folder, false);
         }
     }
 }
Example #4
0
<?php

/**
 * @package Simple Groupware
 * @link http://www.simple-groupware.de
 * @copyright Simple Groupware Solutions Thomas Bley 2002-2012
 * @license GPLv2
 */
define("NOCONTENT", true);
require "index.php";
if (!sys_is_super_admin($_SESSION["username"])) {
    sys_die(t("{t}Not allowed. Please log in as super administrator.{/t}"));
}
sysconfig::header();
sysconfig::init();
$show_form = true;
if (!empty($_REQUEST["token"])) {
    $no_hash = false;
    if ($_REQUEST["setup_admin_pw"] == "" and $_REQUEST["setup_admin_user"] == SETUP_ADMIN_USER) {
        $_REQUEST["setup_admin_pw"] = SETUP_ADMIN_PW;
        $no_hash = true;
    }
    $no_hash2 = false;
    if ($_REQUEST["setup_admin_pw2"] == "" and $_REQUEST["setup_admin_user2"] == SETUP_ADMIN_USER2) {
        $_REQUEST["setup_admin_pw2"] = SETUP_ADMIN_PW2;
        $no_hash2 = true;
    }
    $error = sysconfig::validate();
    if ($error == "") {
        sysconfig::write_config($no_hash, $no_hash2);
        echo t("{t}Setup: setup-data written to %s.{/t}", "simple_store/config.php");
Example #5
0
 static function process_action_sys()
 {
     @set_time_limit(900);
     switch ($_REQUEST["action_sys"]) {
         case "maintenance":
             if (!sys_validate_token()) {
                 sys_die("{t}Invalid security token{/t}");
             }
             $lock_file = SIMPLE_STORE . "/maintenance.lck";
             if (!file_exists($lock_file)) {
                 touch($lock_file);
                 sys_log_message_alert("info", "{t}Maintenance mode{/t}: {t}Active{/t}");
             } else {
                 unlink($lock_file);
                 sys_log_message_alert("info", "{t}Maintenance mode{/t}: {t}Inactive{/t}");
             }
             break;
         case "clear_locking":
             self::_remove_locks();
             dirs_create_empty_dir(SIMPLE_STORE . "/locking");
             sys_log_message_log("clean", "{t}Locking{/t}");
             break;
         case "clear_output":
             dirs_create_empty_dir(SIMPLE_CACHE . "/smarty");
             dirs_create_empty_dir(SIMPLE_CACHE . "/output");
             dirs_create_empty_dir(SIMPLE_CACHE . "/artichow");
             dirs_create_empty_dir(SIMPLE_CACHE . "/thumbs");
             dirs_create_empty_dir(SIMPLE_CACHE . "/lang");
             self::build_css();
             self::build_js();
             self::build_icons();
             sys_log_message_log("clean", "{t}Output{/t}");
             break;
         case "clear_debug":
             dirs_create_empty_dir(SIMPLE_CACHE . "/debug");
             sys_log_message_log("clean", "{t}Debug-dir{/t}");
             break;
         case "clear_cms":
             dirs_create_empty_dir(SIMPLE_CACHE . "/cms");
             sys_log_message_log("clean", "{t}CMS{/t}");
             break;
         case "clear_ip":
             dirs_create_empty_dir(SIMPLE_CACHE . "/ip");
             if (APC) {
                 apc_clear_cache("user");
             }
             sys_log_message_log("clean", "IP");
             break;
         case "clear_schema":
             dirs_create_empty_dir(SIMPLE_CACHE . "/schema");
             if (APC) {
                 apc_clear_cache("user");
             }
             sys_log_message_log("clean", "{t}Schema{/t}");
             break;
         case "clear_schemadata":
             dirs_create_empty_dir(SIMPLE_CACHE . "/schema_data");
             dirs_create_empty_dir(SIMPLE_CACHE . "/preview");
             if (APC) {
                 apc_clear_cache("user");
             }
             sys_log_message_log("clean", "{t}Schema data{/t}");
             break;
         case "clear_email":
             dirs_create_empty_dir(SIMPLE_CACHE . "/imap");
             dirs_create_empty_dir(SIMPLE_CACHE . "/pop3");
             sys_log_message_log("clean", "{t}E-mail{/t}");
             break;
         case "clean_notifications":
             db_delete("simple_sys_notifications", array("sent='1'"), array());
             sql_table_optimize("simple_sys_notifications");
             sys_log_message_log("clean", "{t}Notifications{/t}");
             break;
         case "clear_upload":
             dirs_create_empty_dir(SIMPLE_CACHE . "/upload");
             sys_log_message_log("clean", "{t}Uploaded files{/t}");
             break;
         case "clean_tables":
             db_optimize_tables();
             sys_log_message_log("clean", "{t}Optimize Tables{/t}");
             break;
         case "clean_statistics":
             if (!sys_validate_token()) {
                 sys_die("{t}Invalid security token{/t}");
             }
             db_delete("simple_sys_stats", array(), array());
             sql_table_optimize("simple_sys_stats");
             sys_log_message_log("clean", "{t}Statistics{/t}");
             break;
         case "clean_events":
             if (!sys_validate_token()) {
                 sys_die("{t}Invalid security token{/t}");
             }
             db_delete("simple_sys_events", array(), array());
             $folder = db_select_value("simple_sys_tree", "id", "ftype=@type@", array("type" => "sys_events"));
             if (!empty($folder)) {
                 db_delete("simple_sys_search", array("folder=@folder@"), array("folder" => $folder));
             }
             sql_table_optimize("simple_sys_events");
             sql_table_optimize("simple_sys_search");
             sys_log_message_log("clean", "{t}Events{/t}");
             break;
         case "clean_trash":
             if (!sys_validate_token()) {
                 sys_die("{t}Invalid security token{/t}");
             }
             $trash = db_select_value("simple_sys_tree", "id", "anchor=@anchor@", array("anchor" => "trash"));
             if (!empty($trash)) {
                 $folders = db_select("simple_sys_tree", array("id", "fmountpoint"), "parent=@parent@", "", "", array("parent" => $trash));
                 if (is_array($folders) and count($folders) > 0) {
                     foreach ($folders as $folder) {
                         if (!empty($folder["fmountpoint"])) {
                             continue;
                         }
                         folders::delete($folder["id"]);
                     }
                 }
             }
             dirs_create_empty_dir(SIMPLE_STORE . "/trash");
             sys_log_message_log("clean", "{t}Trash{/t}");
             sys_redirect("index.php?" . sys::$urladdon);
             break;
         case "clean_cache":
             $dirs = array(SIMPLE_STORE . "/cron", SIMPLE_CACHE . "/imap", SIMPLE_CACHE . "/pop3", SIMPLE_CACHE . "/smarty", SIMPLE_CACHE . "/cms", SIMPLE_CACHE . "/cifs", SIMPLE_CACHE . "/gdocs", SIMPLE_CACHE . "/lang", SIMPLE_CACHE . "/output", SIMPLE_CACHE . "/artichow", SIMPLE_CACHE . "/thumbs", SIMPLE_CACHE . "/schema");
             foreach ($dirs as $dir) {
                 self::_dirs_clean_dir($dir, 2592000);
             }
             // 30 days
             self::_remove_locks();
             $dirs = array(SIMPLE_CACHE . "/schema_data", SIMPLE_CACHE . "/preview", SIMPLE_STORE . "/locking", SIMPLE_CACHE . "/upload", SIMPLE_CACHE . "/ip", SIMPLE_CACHE . "/debug", SIMPLE_CACHE . "/updater", SIMPLE_CACHE . "/backup");
             foreach ($dirs as $dir) {
                 self::_dirs_clean_dir($dir, 86400);
             }
             // 1 day
             sys_log_message_log("clean", "{t}Clean Cache{/t}");
             sys_redirect("index.php?" . sys::$urladdon);
             break;
         case "clear_setup":
             if (!sys_validate_token()) {
                 sys_die("{t}Invalid security token{/t}");
             }
             @unlink("simple_store/config.php");
             @unlink("simple_store/config_old.php");
             header("Location: index.php");
             exit;
             break;
         case "backup":
             self::_create_backup($_SESSION["folder"]);
             self::_out("<br><a href='index.php?folder=^system/!sys_nodb_backups'>{t}Continue{/t}</a>");
             exit;
             break;
         case "restore_newer":
             self::$_restore_onlynewer = true;
             echo self::_restore($_REQUEST["file"]);
             self::_out("<br><a href='index.php'>{t}Continue{/t}</a>");
             exit;
             break;
         case "restore":
             echo self::_restore($_REQUEST["file"]);
             self::_out("<br><a href='index.php'>{t}Continue{/t}</a>");
             exit;
             break;
         case "restore_here":
             self::$_restore_here = true;
             echo self::_restore($_REQUEST["file"]);
             self::_out("<br><a href='index.php'>{t}Continue{/t}</a>");
             exit;
             break;
         case "restore_missing":
             self::$_restore_missing = true;
             echo self::_restore($_REQUEST["file"]);
             self::_out("<br><a href='index.php'>{t}Continue{/t}</a>");
             exit;
             break;
         case "rebuild_search":
             if (!sys_validate_token()) {
                 sys_die("{t}Invalid security token{/t}");
             }
             self::rebuild_schema(true);
             self::_out("<br><a href='index.php'>{t}Continue{/t}</a>");
             exit;
             break;
         case "clear_session":
             if (!sys_validate_token()) {
                 sys_die("{t}Invalid security token{/t}");
             }
             db_delete("simple_sys_session", array(), array());
             if (APC) {
                 apc_clear_cache("user");
             }
             sys_log_message_log("clean", "{t}Sessions{/t}");
             self::_out("<br><a href='index.php'>{t}Continue{/t}</a>");
             exit;
             break;
         case "phpinfo":
             echo "System time: " . date("c") . "<br>";
             echo "Database time: " . sgsml_parser::sql_date();
             phpinfo();
             exit;
             break;
     }
 }
 static function parse_schema($data, $tname, $cache_time, $cache_file)
 {
     $parser = xml_parser_create("utf-8");
     xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
     $values = "";
     $tags = "";
     xml_parse_into_struct($parser, $data, $values, $tags);
     xml_parser_free($parser);
     $tables = array();
     $extra_types = array("TAB", "SINGLEBUTTON", "VIEWBUTTON", "VIEW", "ROWFILTER", "ROWVALIDATE");
     $i = 0;
     if (!isset($tags["TABLE"]) or !is_array($tags["TABLE"]) or count($tags["TABLE"]) != 2) {
         return array();
     }
     $tag = $tags["TABLE"][0];
     $tfields = array();
     if ($values[$tag]["type"] == "open" and $values[$tags["TABLE"][1]]["type"] == "close" and isset($values[$tag]["attributes"]["NAME"]) and $values[$tag]["attributes"]["NAME"] != "" and $tags["TABLE"][1] - $tag > 3) {
         $ttemp = array_slice($values, $tag, $tags["TABLE"][1] - $tag);
         $att = $values[$tag]["attributes"];
         $tmarker = "";
         foreach (array_keys($ttemp) as $tkey) {
             if ($ttemp[$tkey]["tag"] == "FIELD") {
                 $i = 2;
             } else {
                 if ($ttemp[$tkey]["tag"] == "VIEW") {
                     $i = 1;
                 } else {
                     if ($ttemp[$tkey]["tag"] == "TAB") {
                         $i = 3;
                     } else {
                         if ($ttemp[$tkey]["tag"] == "VIEWBUTTON") {
                             $i = 4;
                         } else {
                             if ($ttemp[$tkey]["tag"] == "SINGLEBUTTON") {
                                 $i = 5;
                             } else {
                                 if ($ttemp[$tkey]["tag"] == "ROWFILTER") {
                                     $i = 6;
                                 } else {
                                     if ($ttemp[$tkey]["tag"] == "ROWVALIDATE") {
                                         $i = 7;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             if ($i > 0 and $ttemp[$tkey]["type"] == "complete" and isset($ttemp[$tkey]["attributes"]["NAME"]) and $ttemp[$tkey]["attributes"]["NAME"] != "" and (isset($ttemp[$tkey]["attributes"]["SIMPLE_TYPE"]) or in_array($ttemp[$tkey]["tag"], $extra_types))) {
                 $tfields[$i][$ttemp[$tkey]["attributes"]["NAME"]] = $ttemp[$tkey]["attributes"];
             } else {
                 if ($i > 0 and $ttemp[$tkey]["type"] == "open" and isset($ttemp[$tkey]["attributes"]["NAME"]) and $ttemp[$tkey]["attributes"]["NAME"] != "" and (isset($ttemp[$tkey]["attributes"]["SIMPLE_TYPE"]) or in_array($ttemp[$tkey]["tag"], $extra_types))) {
                     $tmarker = $ttemp[$tkey]["attributes"]["NAME"];
                     $tfields[$i][$tmarker] = $ttemp[$tkey]["attributes"];
                 } else {
                     if ($i > 0 and $ttemp[$tkey]["type"] == "close") {
                         $tmarker = "";
                         $i = 0;
                     } else {
                         if ($tmarker != "" and $ttemp[$tkey]["type"] == "complete") {
                             if (isset($ttemp[$tkey]["attributes"]) and count($ttemp[$tkey]["attributes"]) > 0) {
                                 $tfields[$i][$tmarker][$ttemp[$tkey]["tag"]][] = $ttemp[$tkey]["attributes"];
                             } else {
                                 $tfields[$i][$tmarker][$ttemp[$tkey]["tag"]] = "";
                             }
                         }
                     }
                 }
             }
         }
     }
     if (count($tfields) > 1 and count($att) > 0) {
         $views = $tfields[1];
         $fields = $tfields[2];
         $tabs = isset($tfields[3]) ? $tfields[3] : array("general" => "");
         $buttons = isset($tfields[4]) ? $tfields[4] : array();
         $singlebuttons = isset($tfields[5]) ? $tfields[5] : array();
         $rowfilters = isset($tfields[6]) ? $tfields[6] : array();
         $rowvalidates = isset($tfields[7]) ? $tfields[7] : array();
         foreach ($buttons as $bkey => $button) {
             if (empty($buttons[$bkey]["ICON"]) and file_exists(sys_custom("ext/icons/" . $button["NAME"] . ".gif"))) {
                 $buttons[$bkey]["ICON"] = $button["NAME"] . ".gif";
             }
         }
         foreach ($singlebuttons as $bkey => $button) {
             if (empty($singlebuttons[$bkey]["ICON"]) and file_exists(sys_custom("ext/icons/" . $button["NAME"] . ".gif"))) {
                 $singlebuttons[$bkey]["ICON"] = $button["NAME"] . ".gif";
             }
         }
         foreach ($fields as $key => $field) {
             if (!empty($field["LINK"])) {
                 foreach ($field["LINK"] as $lkey => $link) {
                     $icon = isset($link["ICON"]) ? $link["ICON"] : "";
                     $pos = isset($link["ALIGN"]) ? $link["ALIGN"] : "";
                     $link = $link["VALUE"];
                     if ($link[0] == "@") {
                         $link = array("_blank", substr($link, 1), $icon, $pos);
                     } else {
                         if ($link[0] == "#") {
                             $link = array("pane", substr($link, 1), $icon, $pos);
                         } else {
                             if ($link[0] == "%") {
                                 $link = array("pane2", substr($link, 1), $icon, $pos);
                             } else {
                                 $link = array("_top", $link, $icon, $pos);
                             }
                         }
                     }
                     $fields[$key]["LINK"][$lkey]["VALUE"] = $link;
                 }
             }
             if (!empty($field["LINKTEXT"])) {
                 foreach ($field["LINKTEXT"] as $lkey => $link) {
                     $link = $link["VALUE"];
                     if ($link[0] == "@") {
                         $link = array("_blank", substr($link, 1));
                     } else {
                         if ($link[0] == "#") {
                             $link = array("pane", substr($link, 1));
                         } else {
                             if ($link[0] == "%") {
                                 $link = array("pane2", substr($link, 1));
                             } else {
                                 $link = array("_top", $link);
                             }
                         }
                     }
                     $fields[$key]["LINKTEXT"][$lkey]["VALUE"] = $link;
                 }
             }
             if (isset($fields[$key]["ONLYIN"][0]["VIEWS"])) {
                 $fields[$key]["ONLYIN"] = explode("|", $fields[$key]["ONLYIN"][0]["VIEWS"]);
             }
             if (isset($fields[$key]["NOTIN"][0]["VIEWS"])) {
                 $fields[$key]["NOTIN"] = explode("|", $fields[$key]["NOTIN"][0]["VIEWS"]);
             }
             if (isset($fields[$key]["READONLYIN"][0]["VIEWS"])) {
                 $fields[$key]["READONLYIN"] = explode("|", $fields[$key]["READONLYIN"][0]["VIEWS"]);
             }
             if (isset($fields[$key]["HIDDENIN"][0]["VIEWS"])) {
                 $fields[$key]["HIDDENIN"] = explode("|", $fields[$key]["HIDDENIN"][0]["VIEWS"]);
             }
             if (isset($fields[$key]["SIMPLE_TYPE"]) and $fields[$key]["SIMPLE_TYPE"] == "id") {
                 $att["ID"] = $key;
             }
             if (!isset($fields[$key]["SIMPLE_TAB"])) {
                 $fields[$key]["SIMPLE_TAB"] = array(key($tabs));
             } else {
                 $fields[$key]["SIMPLE_TAB"] = explode("|", $fields[$key]["SIMPLE_TAB"]);
             }
             if (isset($fields[$key]["DATA"])) {
                 $values = array();
                 $titles = array();
                 foreach ($fields[$key]["DATA"] as $data_item) {
                     if (isset($data_item["VALUES"])) {
                         $vals = array();
                         foreach (explode("|", $data_item["VALUES"]) as $value) {
                             $value = explode("_##_", $value);
                             $vals[$value[0]] = isset($value[1]) ? $value[1] : $value[0];
                         }
                         if (isset($data_item["REVERSE"])) {
                             $vals2 = str_replace("_##_", "=>", $data_item["VALUES"]);
                             $fields[$key]["FILTER"][] = array("VIEWS" => "all", "FUNCTION" => "switch_items|" . $vals2);
                         }
                         if (isset($data_item["SORT"])) {
                             switch ($data_item["SORT"]) {
                                 case "asc":
                                     asort($vals);
                                     if ($skey = array_search("{t}Other{/t}", $vals)) {
                                         unset($vals[$skey]);
                                         $vals[$skey] = "{t}Other{/t}";
                                     }
                                     break;
                                 case "desc":
                                     arsort($vals);
                                     break;
                             }
                         }
                         $values[] = $vals;
                     }
                     // TODO reverse function?
                     if (isset($data_item["FUNCTION"])) {
                         $values[] = array("_FUNCTION_" => $data_item["FUNCTION"]);
                     }
                     if (isset($data_item["TITLE"])) {
                         $titles[] = $data_item["TITLE"];
                     } else {
                         $titles[] = "";
                     }
                 }
                 $fields[$key]["DATA"] = $values;
                 $fields[$key]["DATA_TITLE"] = $titles;
             }
             if (!isset($fields[$key]["SIMPLE_DEFAULT"])) {
                 $fields[$key]["SIMPLE_DEFAULT"] = "";
             } else {
                 $fields[$key]["SIMPLE_DEFAULT"] = str_replace("\\n", "\n", $fields[$key]["SIMPLE_DEFAULT"]);
             }
         }
         $tables["att"] = $att;
         $tables["views"] = $views;
         $tables["fields"] = $fields;
         $tables["data"] = array("tabs" => $tabs, "buttons" => $buttons, "singlebuttons" => $singlebuttons, "rowfilters" => $rowfilters, "rowvalidates" => $rowvalidates);
         $att =& $tables["att"];
         $tabs =& $tables["data"]["tabs"];
         $rowfilters =& $tables["data"]["rowfilters"];
         $rowvalidates =& $tables["data"]["rowvalidates"];
         $singlebuttons =& $tables["data"]["singlebuttons"];
         $buttons =& $tables["data"]["buttons"];
         $fields =& $tables["fields"];
         if (!isset($att["ID"])) {
             $att["ID"] = "id";
         }
         if (!isset($att["SQL_HANDLER"])) {
             $att["SQL_HANDLER"] = "";
         }
         if (!isset($att["GROUP"])) {
             $att["GROUP"] = "";
         }
         if (!isset($att["DEFAULT_SQL"])) {
             $att["DEFAULT_SQL"] = "";
         }
         if (!isset($att["NOSQLWHERE"])) {
             $att["NOSQLWHERE"] = "";
         }
         if (!isset($att["NOSQLFOLDER"])) {
             $att["NOSQLFOLDER"] = "";
         }
         if (!empty($att["CUST_NAME"])) {
             $att["CUSTOM_NAME"] = $att["CUST_NAME"];
         }
         if (!isset($att["CUSTOM_NAME"])) {
             $att["CUSTOM_NAME"] = "";
         }
         if (!isset($att["TEMPLATE"])) {
             $att["TEMPLATE"] = "";
         }
         if (!isset($att["SCHEMA_MODE"])) {
             $att["SCHEMA_MODE"] = "";
         }
         if (!isset($att["GROUPBY"])) {
             $att["GROUPBY"] = "";
         }
         if (!isset($att["ORDERBY"])) {
             $att["ORDERBY"] = $att["ID"];
         }
         if (!isset($att["ORDER"])) {
             $att["ORDER"] = "asc";
         }
         if (!isset($att["LIMIT"])) {
             $att["LIMIT"] = 20;
         }
         if (!isset($att["ENABLE_CALENDAR"])) {
             $att["ENABLE_CALENDAR"] = "";
         }
         if (!isset($att["HIDE_CALENDAR"])) {
             $att["HIDE_CALENDAR"] = "";
         }
         if (!isset($att["WHERE"])) {
             $att["WHERE"] = array();
         } else {
             $att["WHERE"] = array($att["WHERE"]);
         }
         if (!isset($att["DOUBLECLICK"])) {
             $att["DOUBLECLICK"] = "";
         }
         foreach (array_keys($tables["views"]) as $key) {
             if (empty($att["DEFAULT_VIEW"])) {
                 $att["DEFAULT_VIEW"] = $key;
             }
             $view =& $tables["views"][$key];
             $view["views"] =& $tables["views"];
             if (empty($view["ICON"]) and file_exists(sys_custom("ext/icons/" . $view["NAME"] . ".gif"))) {
                 $view["ICON"] = $view["NAME"] . ".gif";
             }
             $view["modulename"] =& $att["MODULENAME"];
             $view["id"] =& $att["ID"];
             $view["filters"] = array();
             $view["restore"] = array();
             $view["rowfilters"] = array();
             $view["rowvalidates"] = array();
             $view["fields"] = array();
             $view["links"] = array();
             $view["linkstext"] = array();
             $view["filters"] = array();
             $view["buttons"] = array();
             $view["singlebuttons"] = array();
             $view["SQLWHERE"] = array();
             $view["SQLWHERE_DEFAULT"] = array();
             if (isset($view["HIDE_TABS"])) {
                 $view["tabs"] = array();
                 $h_tabs = explode("|", $view["HIDE_TABS"]);
                 foreach (array_keys($tabs) as $tkey) {
                     if (!in_array($tkey, $h_tabs) and !in_array("all", $h_tabs)) {
                         $view["tabs"][$tkey] =& $tabs[$tkey];
                     }
                 }
             } else {
                 $view["tabs"] =& $tabs;
             }
             if (count($rowfilters) > 0) {
                 foreach ($rowfilters as $rkey => $rowfilter) {
                     $r_views = explode("|", $rowfilter["VIEWS"]);
                     if (in_array($key, $r_views) or in_array("all", $r_views)) {
                         $view["rowfilters"][] =& $rowfilters[$rkey];
                     }
                 }
             }
             if (count($rowvalidates) > 0) {
                 foreach (array_keys($rowvalidates) as $rkey) {
                     $view["rowvalidates"][] =& $rowvalidates[$rkey];
                 }
             }
             foreach (array_keys($fields) as $fkey) {
                 $field =& $fields[$fkey];
                 $addfield = true;
                 if (!empty($field["MULTIPLE"])) {
                     $field["SEPARATOR"] = $field["MULTIPLE"];
                 }
                 if (!empty($field["SEPARATOR"])) {
                     $field["SEPARATOR"] = str_replace("\\n", "\n", $field["SEPARATOR"]);
                 }
                 if (isset($field["NOTINALL"])) {
                     $addfield = false;
                 }
                 if (isset($field["NOTIN"]) and in_array($key, $field["NOTIN"])) {
                     $addfield = false;
                 }
                 if (isset($field["ONLYIN"])) {
                     if (in_array($key, $field["ONLYIN"])) {
                         $addfield = true;
                     } else {
                         $addfield = false;
                     }
                 }
                 if (!empty($view["SHOWONLY"])) {
                     if (!in_array($field["NAME"], explode("|", $view["SHOWONLY"]))) {
                         $addfield = false;
                     }
                 }
                 if ($addfield) {
                     if (!empty($field["READONLYIN"]) and in_array("all", $field["READONLYIN"])) {
                         $field["READONLYIN"]["all"] = "true";
                     }
                     if (!empty($field["READONLYIN"]) and in_array($key, $field["READONLYIN"])) {
                         $field["READONLYIN"][$key] = "true";
                     }
                     if (!empty($field["HIDDEN"]) or !empty($field["HIDDENIN"]) and in_array("all", $field["HIDDENIN"])) {
                         $field["HIDDENIN"]["all"] = "true";
                     }
                     if (!empty($field["HIDDENIN"]) and in_array($key, $field["HIDDENIN"])) {
                         $field["HIDDENIN"][$key] = "true";
                     }
                     $view["fields"][$field["NAME"]] =& $field;
                 }
                 if (!empty($field["LINK"])) {
                     foreach ($field["LINK"] as $lkey => $link) {
                         if (empty($link["VIEWS"])) {
                             $view["links"][$field["NAME"]] =& $field["LINK"][$lkey]["VALUE"];
                         } else {
                             $fviews = explode("|", $link["VIEWS"]);
                             if (in_array($key, $fviews) or in_array("all", $fviews)) {
                                 $view["links"][$field["NAME"]] =& $field["LINK"][$lkey]["VALUE"];
                             }
                         }
                     }
                 }
                 if (!empty($field["LINKTEXT"])) {
                     foreach ($field["LINKTEXT"] as $lkey => $link) {
                         if (empty($link["VIEWS"])) {
                             $view["linkstext"][$field["NAME"]] =& $field["LINKTEXT"][$lkey]["VALUE"];
                         } else {
                             $fviews = explode("|", $link["VIEWS"]);
                             if (in_array($key, $fviews) or in_array("all", $fviews)) {
                                 $view["linkstext"][$field["NAME"]] =& $field["LINKTEXT"][$lkey]["VALUE"];
                             }
                         }
                     }
                 }
                 if (isset($field["FILTER"])) {
                     foreach ($field["FILTER"] as $fikey => $filter) {
                         $fviews = explode("|", $filter["VIEWS"]);
                         if (in_array($key, $fviews) or in_array("all", $fviews)) {
                             $view["filters"][$field["NAME"]][] =& $field["FILTER"][$fikey];
                         }
                     }
                 }
                 if (isset($field["RESTORE"])) {
                     foreach ($field["RESTORE"] as $rekey => $restore) {
                         if (!empty($restore["VIEWS"])) {
                             $fviews = explode("|", $restore["VIEWS"]);
                             if (!in_array($key, $fviews) and !in_array("all", $fviews)) {
                                 continue;
                             }
                         }
                         $view["restore"][$field["NAME"]][] =& $field["RESTORE"][$rekey];
                     }
                 }
             }
             if (!isset($view["SQL_HANDLER"])) {
                 $view["SQL_HANDLER"] = $att["SQL_HANDLER"];
             }
             if (!isset($view["GROUP"])) {
                 $view["GROUP"] = $att["GROUP"];
             }
             if (!isset($view["DEFAULT_SQL"])) {
                 $view["DEFAULT_SQL"] = $att["DEFAULT_SQL"];
             }
             if (!isset($view["NOSQLFOLDER"])) {
                 $view["NOSQLFOLDER"] = $att["NOSQLFOLDER"];
             }
             if (!isset($view["NOSQLWHERE"])) {
                 $view["NOSQLWHERE"] = $att["NOSQLWHERE"];
             }
             if (!isset($view["TEMPLATE"])) {
                 $view["TEMPLATE"] = $att["TEMPLATE"];
             }
             if (!isset($view["SCHEMA_MODE"])) {
                 $view["SCHEMA_MODE"] = $att["SCHEMA_MODE"];
             }
             if (!isset($view["GROUPBY"])) {
                 $view["GROUPBY"] = $att["GROUPBY"];
             }
             if (!isset($view["ORDERBY"])) {
                 $view["ORDERBY"] = $att["ORDERBY"];
             }
             if (!isset($view["ORDER"])) {
                 $view["ORDER"] = $att["ORDER"];
             }
             if (!isset($view["LIMIT"])) {
                 $view["LIMIT"] = $att["LIMIT"];
             }
             if (!isset($view["ENABLE_CALENDAR"])) {
                 $view["ENABLE_CALENDAR"] = $att["ENABLE_CALENDAR"];
             }
             if (!isset($view["HIDE_CALENDAR"])) {
                 $view["HIDE_CALENDAR"] = $att["HIDE_CALENDAR"];
             }
             if (!isset($view["DOUBLECLICK"])) {
                 $view["DOUBLECLICK"] = $att["DOUBLECLICK"];
             }
             if (empty($view["WHERE"])) {
                 $view["WHERE"] = $att["WHERE"];
             } else {
                 $view["WHERE"] = array_merge(array($view["WHERE"]), $att["WHERE"]);
             }
             if (!empty($view["NOVIEWBUTTONS"]) and !in_array($view["NOVIEWBUTTONS"], array("all", "true"))) {
                 $f_no_buttons = explode("|", $view["NOVIEWBUTTONS"]);
                 $view["NOVIEWBUTTONS"] = "";
                 // != all|true
             } else {
                 $f_no_buttons = array();
             }
             foreach ($buttons as $bkey => $button) {
                 $addit = true;
                 if (isset($button["VIEWS"]) and !in_array($key, explode("|", $button["VIEWS"]))) {
                     $addit = false;
                 }
                 if (in_array($bkey, $f_no_buttons)) {
                     $addit = false;
                 }
                 if ($addit) {
                     $view["buttons"][$bkey] =& $buttons[$bkey];
                 }
             }
             if (!empty($view["NOSINGLEBUTTONS"]) and !in_array($view["NOSINGLEBUTTONS"], array("all", "true"))) {
                 $f_no_singlebuttons = explode("|", $view["NOSINGLEBUTTONS"]);
                 $view["NOSINGLEBUTTONS"] = "";
                 // != all|true
             } else {
                 $f_no_singlebuttons = array();
             }
             foreach ($singlebuttons as $bkey => $button) {
                 $addit = true;
                 if (isset($button["VIEWS"])) {
                     $sviews = explode("|", $button["VIEWS"]);
                     if (!in_array($key, $sviews) and !in_array("all", $sviews)) {
                         $addit = false;
                     }
                 }
                 if (in_array($bkey, $f_no_singlebuttons)) {
                     $addit = false;
                 }
                 if ($addit) {
                     $view["singlebuttons"][$bkey] =& $singlebuttons[$bkey];
                 }
             }
             $view["SQLWHERE"][] = "id in (@item@)";
             if (isset($fields["folder"]) and empty($view["NOSQLFOLDER"])) {
                 $view["SQLWHERE"][] = "folder in (@folders@)";
                 $view["SQLWHERE_DEFAULT"][] = "folder in (@folders@)";
             }
             if (empty($view["NOSQLWHERE"]) and count($view["WHERE"]) > 0) {
                 $view["SQLWHERE"] = array_merge($view["SQLWHERE"], $view["WHERE"]);
                 $view["SQLWHERE_DEFAULT"] = array_merge($view["SQLWHERE_DEFAULT"], $view["WHERE"]);
             }
             $tables[$key] = array("view" => $key, "att" => &$att, "views" => array($key => &$view), "fields" => &$fields);
         }
         if (!sys_strbegins($tname, "nodb_") and !self::_apply_schema($att["NAME"], $fields)) {
             sys_die("{t}Modifying database failed.{/t}");
         }
     }
     if (!isset($att["NAME"]) or !isset($att["DEFAULT_VIEW"]) or !isset($views[$att["DEFAULT_VIEW"]]) or count($fields) == 0) {
         return array();
     }
     if (count($tables) > 0) {
         if (APC) {
             apc_store("sgsml" . basename($cache_file) . $cache_time, $tables);
         } else {
             file_put_contents($cache_file, serialize($tables), LOCK_EX);
             sys_touch($cache_file, $cache_time);
         }
     }
     return $tables;
 }
Example #7
0
 function render($pagename)
 {
     $page = PageDbStore::read($pagename);
     if (empty($page["id"])) {
         global $FmtPV;
         $FmtPV['$RequestedPage'] = "'{$pagename}'";
         $page = PageDbStore::read("Site.PageNotFound");
         if (empty($page["id"])) {
             sys_die("{t}Page not found{/t}: " . $pagename . ", Site.PageNotFound");
         }
     }
     if (isset($_REQUEST["source"])) {
         return "<code>" . nl2br(q($page["data"])) . "</code>";
     }
     return pmwiki_render($page["pagename"], "(:groupheader:)" . $page["data"] . "(:groupfooter:)", "simple_cms", $page["staticcache"], $page["lastmodified"]);
 }
Example #8
0
 static function shutdown()
 {
     // check execution time
     self::$time_end = number_format(sys_get_microtime() - self::$time_start, 2);
     if (self::$time_end > SYSTEM_SLOW) {
         sys_log_message_log("system-slow", sprintf("{t}%s secs{/t}", self::$time_end) . " " . basename(_sys_request_uri()), _sys_request_uri());
     }
     // process error.txt
     $size = @filesize(SIMPLE_CACHE . "/debug/error.txt");
     if ($size > 0 and $size <= 2097152 and $msgs = @file_get_contents(SIMPLE_CACHE . "/debug/error.txt")) {
         // 2M
         @unlink(SIMPLE_CACHE . "/debug/error.txt");
         $msgs = array_reverse(explode("\n", $msgs));
         foreach ($msgs as $msg) {
             if ($msg == "") {
                 continue;
             }
             $vars = unserialize($msg);
             sys_log_message($vars[0], $vars[1], $vars[2], $vars[3], true, $vars[4]);
         }
     } else {
         if ($size > 0) {
             sys_die("{t}The error logfile cannot be processed, too large:{/t} " . SIMPLE_CACHE . "/debug/error.txt");
         }
     }
     // logging
     sys_log_stat("pages", 1);
 }
Example #9
0
 static function validate_login_ldap($username, $password)
 {
     if (!function_exists("ldap_connect")) {
         sys_die(sprintf("{t}%s is not compiled / loaded into PHP.{/t}", "LDAP"));
     }
     $hostname = SETUP_AUTH_HOSTNAME_LDAP;
     $username = preg_replace("/[\\\\*()#!|&=<>~ ]/", "", $username);
     if (empty($username)) {
         sys_die("LDAP: {t}no username submitted{/t}");
     }
     if (!($ds = ldap_connect($hostname))) {
         sys_die(sprintf("{t}LDAP connection to host %s failed.{/t} (anonymous)", $hostname));
     }
     ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
     ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
     if (SETUP_AUTH_LDAP_USER != "") {
         if (!@ldap_bind($ds, SETUP_AUTH_LDAP_USER, SETUP_AUTH_LDAP_PW)) {
             sys_die(sprintf("{t}LDAP connection to host %s failed.{/t}", $hostname));
         }
     } else {
         if (@ldap_bind($ds, $username . (SETUP_AUTH_DOMAIN != "" ? "@" . SETUP_AUTH_DOMAIN : ""), $password)) {
             if (SETUP_AUTH_AUTOCREATE) {
                 trigger::create_ldap_user($ds, "", $username, "sAMAccountName");
             }
             return true;
         } else {
             if (SETUP_AUTH_DOMAIN != "") {
                 sys_log_message_alert("login", sprintf("{t}Login failed from %s.{/t} (ldap-ad) (%s)", _login_get_remoteaddr(), ldap_error($ds)));
                 return false;
             } else {
                 if (!@ldap_bind($ds)) {
                     sys_die("{t}LDAP anonymous connection failed.{/t}");
                 }
             }
         }
     }
     $base_dn = SETUP_AUTH_BASE_DN;
     if ($base_dn == "") {
         $result_id = @ldap_read($ds, "", "(objectclass=*)", array("namingContexts"));
         $attrs = ldap_get_attributes($ds, ldap_first_entry($ds, $result_id));
         if (isset($attrs["namingContexts"]) and is_array($attrs["namingContexts"])) {
             $base_dn = $attrs["namingContexts"][0];
         }
     }
     if ($base_dn == "") {
         sys_die("{t}LDAP: no base DN given{/t}");
     }
     if (SETUP_AUTH_LDAP_UID == "") {
         sys_die("{t}LDAP: no UID given{/t}");
     }
     $res = ldap_search($ds, $base_dn, SETUP_AUTH_LDAP_UID . "=" . $username);
     $message = "";
     if ($res) {
         if (ldap_count_entries($ds, $res) == 1) {
             $dn = ldap_get_dn($ds, ldap_first_entry($ds, $res));
             if (@ldap_bind($ds, $dn, $password)) {
                 if (SETUP_AUTH_AUTOCREATE) {
                     trigger::create_ldap_user($ds, $base_dn, $username, SETUP_AUTH_LDAP_UID);
                 }
                 return true;
             }
         } else {
             $message = "{t}User not found.{/t} base_dn: " . $base_dn . " {t}Search{/t}: " . SETUP_AUTH_LDAP_UID . "=" . $username;
         }
     }
     if ($message == "") {
         $message = ldap_error($ds);
     }
     sys_log_message_alert("login", sprintf("{t}Login failed from %s.{/t} (ldap) (%s)", _login_get_remoteaddr(), $message));
     return false;
 }
Example #10
0
    exit(json_encode($result));
}
$tpl = new template();
$tpl->console = $_REQUEST["console"];
$code = "";
$tlimit = 0;
$mlimit = 0;
if (!empty($_REQUEST["code"])) {
    if (!sys_validate_token()) {
        sys_die(t("{t}Invalid security token{/t}"));
    }
    $code = $_REQUEST["code"];
}
if (!empty($_REQUEST["name"])) {
    if (!sys_validate_token()) {
        sys_die(t("{t}Invalid security token{/t}"));
    }
    $code = db_select_value("simple_sys_console", "command", "name=@name@", array("name" => $_REQUEST["name"]));
}
if (!empty($_REQUEST["tlimit"])) {
    $tlimit = (int) $_REQUEST["tlimit"];
}
if (!empty($_REQUEST["mlimit"])) {
    $mlimit = (int) $_REQUEST["mlimit"];
}
$tpl->code = $code;
$tpl->tlimit = $tlimit ? $tlimit : "";
$tpl->mlimit = $mlimit ? $mlimit : "";
if ($tlimit > 0) {
    set_time_limit($tlimit);
}
Example #11
0
<?php

if (!defined("MAIN_SCRIPT")) {
    exit;
}
@error_reporting(E_ALL & ~E_NOTICE);
if (!sys_is_super_admin($_SESSION["username"])) {
    sys_die("Not allowed. Please log in as super administrator.");
}
if ((!empty($_GET) or !empty($_POST)) and !array_key_exists($_REQUEST["token"], $_SESSION["tokens"])) {
    sys_die("Invalid security token.");
}
$token = md5(uniqid(rand(), true));
$_SESSION["tokens"][$token] = 1;
/*
 * webadmin.php - a simple Web-based file manager
 * Copyright (C) 2004  Daniel Wacker <*****@*****.**>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Example #12
0
 private static function _connect($mfolder)
 {
     static $cache = array();
     if (empty($cache[$mfolder])) {
         $creds = sys_credentials($mfolder);
         if ($creds["server"] == "") {
             return false;
         }
         $basedn = $creds["options"];
         if (!$creds["port"]) {
             $creds["port"] = 389;
         }
         if ($creds["ssl"] and !extension_loaded("openssl")) {
             sys_warning(sprintf("{t}%s is not compiled / loaded into PHP.{/t}", "OpenSSL"));
             return false;
         }
         if (!function_exists("ldap_connect")) {
             sys_warning(sprintf("{t}%s is not compiled / loaded into PHP.{/t}", "LDAP"));
             return false;
         }
         if (!($ds = ldap_connect($creds["server"]))) {
             sys_die(sprintf("{t}LDAP connection to host %s failed.{/t}", $creds["server"]));
         }
         ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3);
         ldap_set_option($ds, LDAP_OPT_REFERRALS, 0);
         if (!@ldap_bind($ds, $creds["username"], $creds["password"])) {
             if (!@ldap_bind($ds)) {
                 sys_warning("{t}LDAP anonymous connection failed.{/t}");
                 return false;
             }
             if ($basedn == "") {
                 $result_id = @ldap_read($ds, "", "(objectclass=*)", array("namingContexts"));
                 $attrs = ldap_get_attributes($ds, ldap_first_entry($ds, $result_id));
                 if (isset($attrs["namingContexts"]) and is_array($attrs["namingContexts"])) {
                     $basedn = $attrs["namingContexts"][0];
                 }
             }
             $creds["username"] = preg_replace("/[\\\\*()#!|&=<>~ ]/", "", $creds["username"]);
             $res = ldap_search($ds, $basedn, "uid=" . $creds["username"]);
             if (ldap_count_entries($ds, $res) == 1) {
                 $dn = ldap_get_dn($ds, ldap_first_entry($ds, $res));
                 if (@ldap_bind($ds, $dn, $creds["password"])) {
                     sys_warning(sprintf("{t}Login failed from %s.{/t} (ldap) (%s)\n{t}(for active directory username must be: username@domain){/t}", _login_get_remoteaddr(), ldap_error($ds)));
                     return false;
                 }
             }
         }
         $cache[$mfolder] = $ds;
     }
     return $cache[$mfolder];
 }
Example #13
0
}
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();
            preg_match($mirror["pattern"], $data, $match);
            if (empty($match[1])) {
                sys_die(t("{t}Error{/t}") . ": file-check " . $mirror["url"]);
            }
            $release = $match[1];
        }
        $source = sprintf($mirror["source"], $release, $release);
    }
}
$temp_folder = SIMPLE_CACHE . "/updater/";
sys_mkdir($temp_folder);
$target = $temp_folder . substr(basename($source), 0, -3);
updater::download($source, $target);
$source_folder = updater::extract($target, $temp_folder);
updater::move_files($move_folders, $source_folder);
updater::extensions();
updater::footer();
Example #14
0
            }
            $output .= " \$" . $param->getName();
            if ($param->isDefaultValueAvailable()) {
                $output .= "=" . str_replace("\n", "", var_export($param->getDefaultValue(), true));
            }
            if ($reflectmethod->getNumberOfParameters() != $num + 1) {
                $output .= ",";
            }
        }
        $output .= " )\n\n";
    }
    sys_die("Simple Groupware Soap/Ajax Functions", $output, true);
}
if (!empty($_SERVER["HTTP_SOAPACTION"])) {
    if (!extension_loaded("soap")) {
        sys_die(t("{t}%s is not compiled / loaded into PHP.{/t}", "Soap"));
    }
    $soap = new SoapServer(null, array('uri' => 'sgs'));
    $soap->setClass($class);
    $soap->handle();
} else {
    if ($_SERVER["HTTP_X_REQUESTED_WITH"] == "XMLHttpRequest") {
        $func = filter_var($_REQUEST["function"], FILTER_SANITIZE_STRING);
        if ($func == "type_pmwikiarea::ajax_render_preview") {
            require "lib/pmwiki/pmwiki.php";
        }
        if ((strpos($func, "_ajax::") or strpos($func, "::ajax_")) and substr_count($func, "::") == 1) {
            list($class, $func) = explode("::", $func);
        }
        ajax::require_method($func, $class);
        if (!empty($_REQUEST["params"])) {