Пример #1
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;
     }
 }
Пример #2
0
 static function create_edit($tfolder, $tview, $mode)
 {
     $errors = array();
     $defaults = array();
     $form_ids = array();
     $saved_ids = array();
     $sgsml = new sgsml($tfolder, $tview, array_keys($_REQUEST["form_fields"]));
     $file_fields = $sgsml->get_fields_by_type("files");
     foreach ($_REQUEST["form_fields"] as $id) {
         $prefix = "form_" . md5($id);
         $result = array();
         foreach ($file_fields as $field_name) {
             if ($error = self::_processfiles($sgsml, $field_name, $id)) {
                 $result[$field_name] = $error;
             }
         }
         if (!sys_validate_token()) {
             $result['token'] = array(array("{t}validation failed{/t}", "{t}Invalid security token{/t} {t}Please activate cookies.{/t}"));
         }
         $data = array();
         foreach ($sgsml->current_fields as $field_name => $field) {
             $prefix_name = $prefix . $field_name;
             if (isset($_REQUEST[$prefix_name])) {
                 $data[$field_name] = $_REQUEST[$prefix_name];
             }
         }
         if (!$result) {
             if ($mode == "create") {
                 $result = $sgsml->insert($data);
             } else {
                 $result = $sgsml->update($data, $id);
             }
         }
         foreach ($sgsml->current_fields as $field_name => $field) {
             if (!isset($data[$field_name])) {
                 continue;
             }
             $defaults[$prefix][$field_name] = is_array($data[$field_name]) ? implode("|", $data[$field_name]) : $data[$field_name];
         }
         if (!is_array($result)) {
             $form_ids[] = $id;
             $saved_ids[] = $result;
             if ($mode == "create") {
                 unset($defaults[$prefix]);
             }
         } else {
             $errors[$prefix] = $result;
         }
     }
     return array($errors, $defaults, $form_ids, $saved_ids);
 }
Пример #3
0
    $result = call_user_func_array(array('funcs', $_GET['func']), explode(',', $_GET['params']));
    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);
Пример #4
0
 static function validate()
 {
     if (!sys_validate_token()) {
         return "{t}Invalid security token{/t}";
     }
     if ($_REQUEST["setup_admin_user"] != SETUP_ADMIN_USER and $validate = validate::username($_REQUEST["setup_admin_user"]) and $validate != "") {
         return "{t}Admin Username{/t}: {t}validation failed{/t} " . $validate;
     }
     if ($_REQUEST["setup_admin_user2"] != "" and $_REQUEST["setup_admin_user2"] != SETUP_ADMIN_USER2 and $validate = validate::username($_REQUEST["setup_admin_user2"]) and $validate != "") {
         return "{t}Admin Username{/t} (2): {t}validation failed{/t} " . $validate;
     }
     if (!is_numeric($_REQUEST["login_timeout"]) or $_REQUEST["login_timeout"] <= 60) {
         return "{t}Session timeout{/t}: {t}validation failed{/t}";
     }
     if ($_REQUEST["setup_db_host"] == "") {
         return "{t}missing field{/t}: {t}Database Hostname / IP{/t}";
     }
     if ($_REQUEST["setup_db_user"] == "") {
         return "{t}missing field{/t}: {t}Database User{/t}";
     }
     if ($_REQUEST["setup_db_name"] == "") {
         return "{t}missing field{/t}: {t}Database Name{/t}";
     }
     if (empty($_REQUEST["setup_auth"])) {
         return "{t}missing field{/t}: {t}Authentication Mode{/t}";
     }
     if (!sql_connect($_REQUEST["setup_db_host"], $_REQUEST["setup_db_user"], $_REQUEST["setup_db_pw"], $_REQUEST["setup_db_name"])) {
         return "{t}Connection to database failed.{/t}\n" . sql_error();
     }
     if (empty($_REQUEST["simple_cache"]) or !is_dir($_REQUEST["simple_cache"])) {
         return "SIMPLE_CACHE: {t}validation failed{/t} " . $_REQUEST["simple_cache"];
     }
     if (empty($_REQUEST["simple_store"]) or !is_dir($_REQUEST["simple_store"])) {
         return "SIMPLE_STORE: {t}validation failed{/t} " . $_REQUEST["simple_store"];
     }
     if (empty($_REQUEST["simple_custom"]) or !is_dir($_REQUEST["simple_custom"])) {
         return "SIMPLE_CUSTOM: {t}validation failed{/t} " . $_REQUEST["simple_custom"];
     }
     if (empty($_REQUEST["simple_ext"]) or !is_dir($_REQUEST["simple_ext"])) {
         return "SIMPLE_EXT: {t}validation failed{/t} " . $_REQUEST["simple_ext"];
     }
     if (!empty($_REQUEST["apc_session"]) and !APC) {
         return sprintf("{t}Please install the php-extension with name '%s'.{/t}", "apc");
     }
     if (strlen($_REQUEST["setup_admin_pw"]) < 5) {
         return "{t}Admin Password{/t}: {t}Password must be not null, min 5 characters.{/t}";
     }
     if (strlen($_REQUEST["setup_admin_pw2"]) < 5 and $_REQUEST["setup_admin_user2"] != "") {
         return "{t}Admin Password{/t} (2): {t}Password must be not null, min 5 characters.{/t}";
     }
     if (!empty($_REQUEST["sync4j"])) {
         echo sprintf("{t}Processing %s ...{/t}", "Funambol schema") . "<br>";
         if (SETUP_DB_TYPE == "mysqli") {
             $data = preg_replace("!/\\*.+?\\*/!s", "", file_get_contents("tools/funambolv7_syncML/mysql/funambol.sql"));
             if ($msg = db_query(explode(";", $data))) {
                 return "funambol.sql [mysql]: " . $msg . "<br>";
             }
         } else {
             if (SETUP_DB_TYPE == "pgsql") {
                 $data = file_get_contents("tools/funambolv7_syncML/postgresql/funambol.sql");
                 if ($msg = db_query($data)) {
                     return "funambol.sql [pgsql]: " . $msg . "<br>";
                 }
             } else {
                 return "{t}Funambol only works with MySQL and PostgreSQL.{/t}<br>";
             }
         }
     }
     return "";
 }
Пример #5
0
}
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();
            preg_match($mirror["pattern"], $data, $match);
            if (empty($match[1])) {
                sys_die(t("{t}Error{/t}") . ": file-check " . $mirror["url"]);