diff --git a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_full.sprx b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_full.sprx index 9a967906..642a5dca 100644 Binary files a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_full.sprx and b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_full.sprx differ diff --git a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_lite.sprx b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_lite.sprx index 0e5e26e0..48038653 100644 Binary files a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_lite.sprx and b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_lite.sprx differ diff --git a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_noncobra.sprx b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_noncobra.sprx index d994705e..acbb4310 100644 Binary files a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_noncobra.sprx and b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_noncobra.sprx differ diff --git a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx index 5d590cdb..5b875f71 100644 Binary files a/_Projects_/updater/pkgfiles/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx and b/_Projects_/updater/pkgfiles/USRDIR/webftp_server_rebug_cobra_ps3mapi.sprx differ diff --git a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server.sprx b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server.sprx index 9a967906..642a5dca 100644 Binary files a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server.sprx and b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server.sprx differ diff --git a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_lite.sprx b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_lite.sprx index 0e5e26e0..48038653 100644 Binary files a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_lite.sprx and b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_lite.sprx differ diff --git a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_noncobra.sprx b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_noncobra.sprx index d994705e..acbb4310 100644 Binary files a/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_noncobra.sprx and b/_Projects_/updater/update/dev_hdd0/plugins/webftp_server_noncobra.sprx differ diff --git a/include/feat/script.h b/include/feat/script.h index 98fe7d18..9e3be2ba 100644 --- a/include/feat/script.h +++ b/include/feat/script.h @@ -4,11 +4,17 @@ // if not exist // if L1 // if R1 +// if login/logout +// if xmb/ingame +// if count +// if copying/mounting // if cobra/nocobra/debug/mamba/ps3hen/dex/firmware x.xx // if titleid // abort if exist // abort if not exist +// while /continue/break/loop (nested loops are not supported) + // :label // goto label // map = @@ -20,10 +26,11 @@ // swap = // ren = +// wait user // wait xmb // wait <1-9 secs> -// wait -// lwait +// wait (timeout 5 seconds) +// lwait (timeout 30 seconds) // logfile // log @@ -46,6 +53,8 @@ #define line buffer /* "line", "path" and "buffer" are synonyms */ #define path buffer /* "line", "path" and "buffer" are synonyms */ #define IS_WEB_COMMAND(line) (islike(line, "/mount") || strstr(line, ".ps3") || strstr(line, "_ps3") || strstr(line, ".lv1?") || strstr(line, ".lv2?")) +#define EXIT_LOOP {mloop = NULL, count = 0; pos = strcasestr(pos + 1, "loop"); if(!pos) break;} // exit loop + static void handle_file_request(const char *wm_url) { @@ -65,16 +74,17 @@ static void parse_script(const char *script_file) sys_addr_t sysmem = sys_mem_allocate(max_size); if(!sysmem) return; - char *buffer, *pos, *dest = NULL, label[24]; u16 l; + char *buffer, *sep, *pos, *mloop = NULL, *dest = NULL, label[24]; u16 l, count = 0; u8 exec_mode = true, enable_db = true, do_else = true; size_t buffer_size; char log_file[STD_PATH_LEN]; strcpy(log_file, SC_LOG_FILE); *label = NULL; reload_script: buffer = (char*)sysmem; buffer_size = read_file(script_file, buffer, max_size, 0); buffer[buffer_size] = 0; - if(*buffer && !strchr(buffer, '\n')) strcat(buffer, "\n"); + if(*buffer) strcat(buffer + buffer_size, "\n"); l = 0, script_running = true; + if(mloop) {buffer = mloop; mloop = NULL;} if(*label) {pos = strcasestr(buffer, label); if(pos) buffer = pos; else *buffer = NULL; *label = NULL;} while(*buffer) @@ -88,6 +98,9 @@ static void parse_script(const char *script_file) // process line pos = strchr(line, '\n'); if(!pos) pos = line; + // process line separator ; + if(BETWEEN('A', *line, 'z')) {sep = strchr(line, ';'); if(sep && (sep < pos)) pos = sep;} + if(pos) { *pos = NULL; //EOL @@ -130,13 +143,16 @@ static void parse_script(const char *script_file) else if(exec_mode) { if(*line == '/') {if(islike(line, "/dev_blind?0")) disable_dev_blind(); else if(IS_WEB_COMMAND(line)) handle_file_request(line);} else - if(_islike(line, "goto ")) {snprintf(label, 24, ":%s", line + 5); goto reload_script;} else + if(_islike(line, "goto ")) {mloop = NULL, snprintf(label, 24, ":%s", line + 5); goto reload_script;} else + if(_islike(line, "loop") || _islike(line, "continue")) goto reload_script; else + if(_islike(line, "break")) {EXIT_LOOP;} else if(_islike(line, "del /")) {path += 4; check_path_tags(path); char *wildcard = strchr(path, '*'); if(wildcard) {*wildcard++ = NULL; scan(path, true, wildcard, SCAN_DELETE, NULL);} else del(path, RECURSIVE_DELETE);} else if(_islike(line, "md /")) {path += 3; check_path_tags(path); mkdir_tree(path);} else if(_islike(line, "wait xmb")) {wait_for_xmb();} else + if(_islike(line, "wait user")) {wait_for_user();} else if(_islike(line, "wait /")) {path += 5; check_path_tags(path); wait_for(path, 5);} else if(_islike(line, "wait ")) {line += 5; sys_ppu_thread_sleep((u8)val(line));} else - if(_islike(line, "lwait /")) {path += 6; check_path_tags(path); wait_for(path, 10);} else + if(_islike(line, "lwait /")) {path += 6; check_path_tags(path); wait_for(path, 30);} else #ifdef PS3MAPI if(_islike(line, "beep")) {play_sound_id((u8)(line[4]));} else #else @@ -157,16 +173,27 @@ static void parse_script(const char *script_file) } else #endif - if(_islike(line, "if ") || _islike(line, "abort if ")) + if(_islike(line, "if ") || _islike(line, "abort if ") || _islike(line, "while ")) { + #define DO_WHILE 6 #define ABORT_IF 9 - bool ret = false; u8 ifmode = (_islike(line, "if ")) ? 3 : ABORT_IF; line += ifmode; do_else = true; + u8 ifmode; + if(_islike(line, "while ")) {ifmode = DO_WHILE, mloop = line;} else ifmode = _islike(line, "if ") ? 3 : ABORT_IF; + line += ifmode; + + bool ret = false; do_else = true; if(_islike(line, "exist /")) {path += 6; check_path_tags(path); ret = file_exists(path);} else if(_islike(line, "not exist /")) {path += 10; check_path_tags(path); ret = not_exists(path);} else if(_islike(line, "Firmware")) {line += 9; ret = IS(fw_version, line);} else if(_islike(line, "noCobra")) {ret = !cobra_version;} else + if(_islike(line, "xmb")) {ret = IS_ON_XMB;} else + if(_islike(line, "ingame")) {ret = IS_INGAME;} else + if(_islike(line, "count ")) {if(!count) {count = (u16)val(line + 6); ret = count;} else ret = --count;} else + if(_islike(line, "copying")) {ret = copy_in_progress;} else + if(_islike(line, "mounting")) {ret = is_mounting;} else + if(_islike(line, "log")) {ret = USER_LOGGEDIN; if(strstr(line, "out")) ret = !ret;} else #if defined(PS3MAPI) || defined(DEBUG_MEM) if(_islike(line, "titleid ")){path += 8; get_game_info(); ret = (strlen(_game_TitleID) >= strlen(path)) ? bcompare(_game_TitleID, path, strlen(path), path) : 0;} else #endif @@ -183,7 +210,19 @@ static void parse_script(const char *script_file) if(_islike(line, "R1")) ret = is_pressed(CELL_PAD_CTRL_R1); } - if(ifmode == ABORT_IF) {if(ret) break;} else if(!ret) exec_mode = false; + if(ifmode == ABORT_IF) + { + if(ret) break; // about script if true + } + else if(!ret) // if condition is false + { + if(ifmode == DO_WHILE) + { + EXIT_LOOP; + } + else + exec_mode = false; // do else or go to end + } } } diff --git a/include/file/file.h b/include/file/file.h index d38b0b3e..909038d8 100644 --- a/include/file/file.h +++ b/include/file/file.h @@ -441,6 +441,11 @@ static u8 wait_for_xmb(void) return (t > MAX_WAIT); // true = timeout } +static void wait_for_user(void) +{ + while(working && !USER_LOGGEDIN) sys_ppu_thread_sleep(3); wait_for_xmb(); +} + static void check_reload(void) { from_reboot = file_exists(WM_NOSCAN_FILE); diff --git a/include/init/vsh.h b/include/init/vsh.h index f6086f74..2a8f525a 100644 --- a/include/init/vsh.h +++ b/include/init/vsh.h @@ -1,5 +1,6 @@ // Explore_Plugin Commands: https://www.psdevwiki.com/ps3/Explore_plugin +#define USER_LOGGEDIN (xusers()->GetCurrentUserNumber() > 0) #define EXPLORE_CLOSE_ALL 3 static void * getNIDfunc(const char * vsh_module, u32 fnid, s32 offset) @@ -55,11 +56,14 @@ static sys_addr_t sys_mem_allocate(u32 bytes) static explore_plugin_interface *get_explore_interface(void) { - int view = View_Find("explore_plugin"); - if(view) - explore_interface = (explore_plugin_interface *)plugin_GetInterface(view, 1); - else - explore_interface = NULL; + explore_interface = NULL; + + if(USER_LOGGEDIN) + { + int view = View_Find("explore_plugin"); + if(view) + explore_interface = (explore_plugin_interface *)plugin_GetInterface(view, 1); + } return explore_interface; } @@ -400,7 +404,7 @@ static int count_items(const char *path) #ifdef COBRA_ONLY static void reload_xmb(u8 use_app) { - if(IS_ON_XMB) + if(IS_ON_XMB && USER_LOGGEDIN) { #ifdef LITE_EDITION if(!cobra_version) @@ -439,7 +443,7 @@ static void reload_xmb(u8 use_app) // hold L2 to cancel reload xmb if(is_pressed(CELL_PAD_CTRL_L2)) return; // hold L2 to cancel reload xmb - if(IS_ON_XMB) + if(IS_ON_XMB && USER_LOGGEDIN) { if((webman_config->reloadxmb == 2) || (!use_app && count_items(HDD0_HOME_DIR) <= 1)) use_app = true; diff --git a/include/www/www_start.h b/include/www/www_start.h index f05aae24..3dcbae9d 100644 --- a/include/www/www_start.h +++ b/include/www/www_start.h @@ -186,9 +186,10 @@ static void start_www(u64 conn_s_p) #endif #ifdef PLAY_MUSIC - if(wait_for_abort(1)) sys_ppu_thread_exit(0); - if(webman_config->music) + if(webman_config->music && USER_LOGGEDIN) { + if(wait_for_abort(1)) sys_ppu_thread_exit(0); + bool is_video = (webman_config->music == 2); sprintf(templn, "Starting %s...\n" "Press O to abort", diff --git a/main.c b/main.c index 052471ff..de785d72 100644 --- a/main.c +++ b/main.c @@ -109,7 +109,7 @@ SYS_MODULE_STOP(wwwd_stop); SYS_MODULE_EXIT(wwwd_stop); #define WM_APPNAME "webMAN" -#define WM_VERSION "1.47.46g MOD" +#define WM_VERSION "1.47.46h MOD" #define WM_APP_VERSION WM_APPNAME " " WM_VERSION #define WEBMAN_MOD WM_APPNAME " MOD"