Skip to content

Commit

Permalink
webMAN MOD 1.43.32
Browse files Browse the repository at this point in the history
- Added contextual right-click menu to File Manager
- urlenc detects if using absolute or relative url
- Fixed display issue in /mkdir.ps3 & /rmdir.ps3
  • Loading branch information
Aldo Vargas committed Aug 6, 2016
1 parent 4c5e5ae commit 9b89c75
Show file tree
Hide file tree
Showing 19 changed files with 93 additions and 63 deletions.
12 changes: 6 additions & 6 deletions include/_mount.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static void game_mount(char *buffer, char *templn, char *param, char *tempstr, u
is_binary=1;

// mount url
urlenc(templn, source, 0);
urlenc(templn, source);

if(!(plen==IS_COPY && !copy_in_progress))
{
Expand Down Expand Up @@ -523,7 +523,7 @@ static void game_mount(char *buffer, char *templn, char *param, char *tempstr, u
get_default_icon(icon, fpath, filename + 1, 0, tempID, -1, 0);
}

urlenc(enc_dir_name, icon, 0);
urlenc(enc_dir_name, icon);
htmlenc(_path, source, 0);

#ifdef COPY_PS3
Expand Down Expand Up @@ -768,7 +768,7 @@ static void game_mount(char *buffer, char *templn, char *param, char *tempstr, u
htmlenc(_path, source, 0);
sprintf(tempstr, "%s <a href=\"%s\">%s</a><hr>", STR_COPYING, templn, _path); strcat(buffer, tempstr);

urlenc(_path, target, 0);
urlenc(_path, target);
sprintf(tempstr, "<a href=\"%s\"><img src=\"%s\" border=0></a><hr>%s %s: ",
_path, enc_dir_name, is_error ? STR_ERROR : "", STR_CPYDEST); strcat(buffer, tempstr);

Expand All @@ -783,7 +783,7 @@ static void game_mount(char *buffer, char *templn, char *param, char *tempstr, u
swap[tlen] = NULL;

strcat(buffer, "<a class=\"f\" href=\"");
urlenc(enc_dir_name, swap, 0);
urlenc(enc_dir_name, swap);
strcat(buffer, enc_dir_name);

htmlenc(enc_dir_name, templn, 1);
Expand All @@ -793,7 +793,7 @@ static void game_mount(char *buffer, char *templn, char *param, char *tempstr, u
strcpy(templn, target+tlen);
}

urlenc(enc_dir_name, target, 0); htmlenc(_path, templn, 0); sprintf(tempstr, HTML_URL, enc_dir_name, _path);
urlenc(enc_dir_name, target); htmlenc(_path, templn, 0); sprintf(tempstr, HTML_URL, enc_dir_name, _path);
////////////////////////

if(strstr(target, "/webftp_server")) {strcat(buffer, tempstr); sprintf(tempstr, "<HR>%s", STR_SETTINGSUPD);} else
Expand Down Expand Up @@ -836,7 +836,7 @@ static void game_mount(char *buffer, char *templn, char *param, char *tempstr, u
if(is_iso || strstr(entry.d_name, "[PS2")!=NULL)
{
if(pcount==0) strcat(buffer, "<br><HR>");
urlenc(enc_dir_name, entry.d_name, 0);
urlenc(enc_dir_name, entry.d_name);
sprintf(templn, "<a href=\"/mount.ps2%s/%s\">%s</a><br>", target, enc_dir_name, entry.d_name);

tlen+=strlen(tempstr);
Expand Down
1 change: 1 addition & 0 deletions include/cpursx.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ static void cpu_rsx_stats(char *buffer, char *templn, char *param, u8 is_ps3_htt
sprintf( templn, "<input type=\"range\" value=\"%i\" min=\"%i\" max=\"95\" style=\"width:600px\" onchange=\"window.location='/cpursx.ps3?fan='+this.value\"><hr>", webman_config->manu, DEFAULT_MIN_FANSPEED);
else
sprintf( templn, "<hr>");

strcat(buffer, templn);

CellRtcTick pTick; cellRtcGetCurrentTick(&pTick); u32 dd, hh, mm, ss;
Expand Down
53 changes: 33 additions & 20 deletions include/file_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void add_list_entry(char *tempstr, bool is_dir, char *ename, char *templn
}

// encode url for html
urlenc(tempstr, templn, 1); strncpy(templn, tempstr, _MAX_LINE_LEN);
if(urlenc(tempstr, templn)) strncpy(templn, tempstr, _MAX_LINE_LEN);

// is image?
u8 show_img = !is_ps3_http && (!is_dir && (!strcasecmp(ext, ".png") || !strcasecmp(ext, ".jpg") || !strcasecmp(ext, ".bmp")));
Expand Down Expand Up @@ -126,14 +126,16 @@ static void add_list_entry(char *tempstr, bool is_dir, char *ename, char *templn
else
sprintf(fsize, "<label title=\"%'llu %s\"> %'llu %s</label>", sbytes, STR_BYTE, sz, sf);

snprintf(ename, 6, "%s ", name); //if(!strstr(templn, ":")) urlenc(templn, tempstr, 1);
snprintf(ename, 6, "%s ", name);

sprintf(tempstr, "%c%c%c%c%c%c<tr>"
"<td><a %s href=\"%s\"%s>%s</a></td>",
is_dir ? '0' : '1', ename[0], ename[1], ename[2], ename[3], ename[4],
is_dir ? "class=\"d\"" : "class=\"w\"", templn, show_img ? " onmouseover=\"s(this,0);\"" : (is_dir && show_icon0) ? " onmouseover=\"s(this,1);\"":"", name);
is_dir ? '0' : '1', ename[0], ename[1], ename[2], ename[3], ename[4],
is_dir ? "class=\"d\"" : "class=\"w\"", templn,
show_img ? " onmouseover=\"s(this,0);\"" : (is_dir && show_icon0) ? " onmouseover=\"s(this,1);\"" : "", name);

flen = strlen(tempstr);

if(flen >= _LINELEN)
{
if(is_dir) sprintf(fsize, HTML_DIR); else sprintf(fsize, "%llu %s", sz, sf);
Expand All @@ -143,7 +145,8 @@ static void add_list_entry(char *tempstr, bool is_dir, char *ename, char *templn
is_dir ? '0' : '1', ename[0], ename[1], ename[2], ename[3], ename[4],
is_dir ? "class=\"d\"" : "class=\"w\"", templn, name);

flen=strlen(tempstr);
flen = strlen(tempstr);

if(flen >= _LINELEN)
{
if(is_dir) sprintf(fsize, HTML_DIR); else sprintf(fsize, "%llu %s", sz, sf);
Expand All @@ -159,6 +162,7 @@ static void add_list_entry(char *tempstr, bool is_dir, char *ename, char *templn
"<td>%02i-%s-%04i %02i:%02i</td></tr>",
fsize, is_root ? "" : " &nbsp; ",
rDate.day, smonth[rDate.month-1], rDate.year, rDate.hour, rDate.minute);

strcat(tempstr, templn);

flen = strlen(tempstr);
Expand All @@ -181,7 +185,7 @@ static void add_breadcrumb_trail(char *buffer, char *param)
swap[tlen] = NULL;

strcat(buffer, "<a class=\"f\" href=\"");
urlenc(url, swap, 0);
urlenc(url, swap);
strcat(buffer, url);

htmlenc(url, templn, 1);
Expand All @@ -196,7 +200,7 @@ static void add_breadcrumb_trail(char *buffer, char *param)
{
char label[_MAX_PATH_LEN];

urlenc(url, param, 0); htmlenc(label, templn, 0);
urlenc(url, param); htmlenc(label, templn, 0);
sprintf(swap, "<a href=\"%s%s\">%s</a>",
#ifdef FIX_GAME
islike(param, HDD0_GAME_DIR) ? "/fixgame.ps3" :
Expand Down Expand Up @@ -275,8 +279,8 @@ static bool folder_listing(char *buffer, u32 BUFFER_SIZE_HTML, char *templn, cha
// F2 = rename/move item pointed with mouse
islike(param, "/dev_") ?
"document.addEventListener('keyup',ku,false);"
"function ku(e){e=e||window.event;if(e.keyCode == 113)"
"{var a=document.querySelectorAll('a:hover')[0].href,f=a.substring(a.indexOf('/',8));if(f.substring(0,5)=='/dev_'){t=prompt('Rename to:',unescape(f));if(t&&t!=a)window.location='/rename.ps3'+f+'|'+escape(t)}}}" : ""); strcat(buffer, templn);
"function rn(f){if(f.substring(0,5)=='/dev_'){f=unescape(f);t=prompt('Rename to:',f);if(t&&t!=f)window.location='/rename.ps3'+f+'|'+escape(t)}}"
"function ku(e){e=e||window.event;if(e.keyCode==113){var a=document.querySelectorAll('a:hover')[0].pathname;rn(a);}}" : ""); strcat(buffer, templn);
}

strcat(buffer, "<table class=\"propfont\"><tr><td>");
Expand Down Expand Up @@ -309,7 +313,7 @@ static bool folder_listing(char *buffer, u32 BUFFER_SIZE_HTML, char *templn, cha
strcpy(templn, param); if(templn[strlen(templn)-1] == '/') templn[strlen(templn)-1] = NULL;
if(strrchr(templn, '/')) templn[strrchr(templn, '/')-templn] = NULL; if(strlen(templn)<6 && strlen(param)<8) {templn[0]='/'; templn[1] = NULL;}

urlenc(swap, templn, 0);
urlenc(swap, templn);
sprintf(line_entry[idx].path, "!00000<tr>"
"<td><a class=\"f\" href=\"%s\">..</a></td>"
"<td> " HTML_URL " &nbsp; </td>"
Expand Down Expand Up @@ -488,13 +492,15 @@ static bool folder_listing(char *buffer, u32 BUFFER_SIZE_HTML, char *templn, cha

tlen = strlen(buffer);

for(u16 m=0;m<idx;m++)
for(u16 m = 0; m < idx; m++)
{
strcat(buffer, (line_entry[m].path)+6); tlen += strlen(buffer + tlen);
strcat(buffer + tlen, (line_entry[m].path)+6); tlen += strlen(buffer + tlen);
if(tlen > BUFFER_SIZE_HTML) break;
}

strcat(buffer + tlen, "</table>");
buffer += tlen;

strcat(buffer, "</table>");

if(strlen(param) > 4)
{
Expand Down Expand Up @@ -536,10 +542,10 @@ static bool folder_listing(char *buffer, u32 BUFFER_SIZE_HTML, char *templn, cha
sprintf(templn, "%s", wm_icons[5]); show_icon = true;
}

for(u16 m=idx;m<7;m++) strcat(buffer + tlen, "<BR>");
for(u16 m = idx; m < 7; m++) strcat(buffer, "<BR>");

if(show_icon || show_icon0)
{urlenc(swap, templn, 0); sprintf(templn, "<script>icon.src=\"%s\"</script>", swap); strcat(buffer + tlen, templn);}
{urlenc(swap, templn); sprintf(templn, "<script>icon.src=\"%s\"</script>", swap); strcat(buffer, templn);}
}
///////////

Expand All @@ -559,8 +565,8 @@ static bool folder_listing(char *buffer, u32 BUFFER_SIZE_HTML, char *templn, cha
}

///////////
if(strchr(param+1, '/'))
param[strchr(param+1, '/')-param] = NULL;
if(strchr(param + 1, '/'))
param[strchr(param + 1, '/')-param] = NULL;

if(param[1] == 'n')
sprintf(templn, "<hr>"
Expand All @@ -574,17 +580,24 @@ static bool folder_listing(char *buffer, u32 BUFFER_SIZE_HTML, char *templn, cha
"<b>" HTML_URL ": %'d %s",
param, param, (int)((blockSize*freeSize)>>20), STR_MBFREE);
}
strcat(buffer + tlen, templn);

// popup menu
sprintf(templn, "<div id='mnu' style='position:fixed;width:140px;background:#555;display:none;padding:5px;'>"
"<a id='m1'>%s</a><a id='m2'>%s</a><hr><a id='m3'>%s</a><hr><a id='m4'>%s</a><br><a id='m5'>%s</a><br><a id='m6'>%s</a><hr><a id='m7'>%s</a><br><a id='m8'>%s</a></div>"
"<script>var s,m;window.addEventListener('contextmenu',function(e){if(s)s.color='#ccc';t=e.target,s=t.style,c=t.className,m=mnu.style,p=t.pathname;if(c=='w'||c=='d'){e.preventDefault();s.color='#fff';m.display='block';m.left=(e.clientX+12)+'px';m.top=(e.clientY+12)+'px';m1.href='/mount.ps3'+p;m1.style.display=(p.toLowerCase().indexOf('.iso')>=0||c=='d')?'block':'none';m2.href=p;m3.href='/delete.ps3'+p;m4.href='/cut.ps3'+p;m5.href='/cpy.ps3'+p;m6.href='/paste.ps3'+window.location.pathname;m7.href='javascript:rn(\"'+t.pathname+'\")';m8.href='/copy.ps3'+p}},false);window.onclick=function(e){if(m)m.display='none';}</script>",
"Mount", "Open", "Delete", "Cut", "Copy", "Paste", "Rename", "Copy To"); strcat(buffer, templn);

// summary
sprintf(templn, "</b> &nbsp; <font color=\"#707070\">%'i Dir(s) %'d %s %'d %s</font>%s",
MAX(dirs - 1, 0), (idx-dirs), STR_FILES,
dir_size<(_1MB_)?(int)(dir_size>>10):(int)(dir_size>>20),
dir_size<(_1MB_)?STR_KILOBYTE:STR_MEGABYTE, tempstr);
strcat(buffer + tlen, templn);

strcat(buffer, templn);
///////////
}
else
strcat(buffer + tlen, HTML_BLU_SEPARATOR
strcat(buffer, HTML_BLU_SEPARATOR
"webMAN - Simple Web Server" EDITION "<br>");
}
return true;
Expand Down
14 changes: 7 additions & 7 deletions include/games_html.h
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ static int add_net_game(int ns, netiso_read_dir_result_data *data, int v3_entry,
sprintf(data[v3_entry].name, "%s", tempstr + strlen(param) + 1);
}

urlenc(enc_dir_name, data[v3_entry].name, 0);
urlenc(enc_dir_name, data[v3_entry].name);
get_default_icon(icon, param, data[v3_entry].name, data[v3_entry].is_directory, tempID, ns, abort_connection);

if(webman_config->nocov<2 && (icon[0]==0 || webman_config->nocov)) {get_name(tempstr, data[v3_entry].name, 1); strcat(tempstr, ".PNG"); if(file_exists(tempstr)) strcpy(icon, tempstr);}
Expand Down Expand Up @@ -780,7 +780,7 @@ static bool game_listing(char *buffer, char *templn, char *param, char *tempstr,
if(filter_name[0]>=' ' && strcasestr(templn, filter_name)==NULL && strcasestr(param, filter_name)==NULL && strcasestr(data[v3_entry].name, filter_name)==NULL) {v3_entry++; continue;}


strcpy(tempstr, icon); urlenc(icon, tempstr, 0);
strcpy(tempstr, icon); urlenc(icon, tempstr);

snprintf(tempstr, 8, "%s ", templn); // sort key

Expand Down Expand Up @@ -917,11 +917,11 @@ static bool game_listing(char *buffer, char *templn, char *param, char *tempstr,

if(webman_config->tid && tempID[0]>'@' && strlen(templn) < 50 && strstr(templn, " [")==NULL) {strcat(templn, " ["); strcat(templn, tempID); strcat(templn, "]");}

urlenc(enc_dir_name, entry.d_name, 0);
urlenc(enc_dir_name, entry.d_name);

templn[64] = NULL; flen = strlen(templn);

urlenc(tempstr, icon, 1);
urlenc(tempstr, icon);

snprintf(tempstr, 8, "%s ", templn); // sort key

Expand Down Expand Up @@ -1030,12 +1030,12 @@ static bool game_listing(char *buffer, char *templn, char *param, char *tempstr,
tlen = buf_len;
for(u16 m = 0; m < idx; m++)
{
strcat(buffer + tlen, (line_entry[m].path) + HTML_KEY_LEN); tlen += strlen((line_entry[m].path) + HTML_KEY_LEN);
if(tlen>(BUFFER_MAXSIZE)) break;
strcat(buffer + tlen, (line_entry[m].path) + HTML_KEY_LEN); tlen += strlen(buffer + tlen);
if(tlen > (BUFFER_MAXSIZE)) break;
}

#ifndef LITE_EDITION
if(sortable) strcat(buffer+tlen, "</div>");
if(sortable) strcat(buffer + tlen, "</div>");
#endif

loading_games = 0;
Expand Down
2 changes: 1 addition & 1 deletion include/games_xml.h
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ static bool update_mygames_xml(u64 conn_s_p)

if(webman_config->tid && tempID[0]>'@' && strlen(templn) < 50 && strstr(templn, " [")==NULL) {strcat(templn, " ["); strcat(templn, tempID); strcat(templn, "]");}

urlenc(enc_dir_name, entry.d_name, 0);
urlenc(enc_dir_name, entry.d_name);

// subfolder name
if(f0==NTFS && entry.d_name[0]=='[')
Expand Down
16 changes: 10 additions & 6 deletions include/html.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,16 @@ static char h2a(char hex)
return c;
}

static void urlenc(char *dst, char *src, u8 rel_mode)
static bool urlenc(char *dst, char *src)
{
size_t j=0;
size_t n=strlen(src);
for(size_t i=0; i<n; i++,j++)
size_t j = 0, n = strlen(src), pos = 0;

if(src[0] == 'h' && src[1] == 't' && src[2] == 't' && src[3] == 'p' && (src[4] == ':' || src[5] == ':') && (n > 7)) pos = MAX((*(const unsigned char*)strchr(src + 7, '/') - *(const unsigned char*)src), 0);

for(size_t i = 0; i < n; i++, j++)
{
if(src[i]==' ') {dst[j++] = '%'; dst[j++] = '2'; dst[j] = '0';}
else if(src[i]==':' && rel_mode) {dst[j++] = '%'; dst[j++] = '3'; dst[j] = 'A';}
else if(src[i]==':' && (i >= pos)) {dst[j++] = '%'; dst[j++] = '3'; dst[j] = 'A';}
else if(src[i] & 0x80)
{
dst[j++] = '%';
Expand All @@ -77,6 +79,8 @@ static void urlenc(char *dst, char *src, u8 rel_mode)
else dst[j] = src[i];
}
dst[j] = '\0';

return (j > n); // true if dst != src
}

static void htmlenc(char *dst, char *src, u8 cpy2src)
Expand Down Expand Up @@ -383,4 +387,4 @@ static u32 get_valuen32(char *param, const char *label)
return 0;
}
#endif
#endif
#endif
26 changes: 16 additions & 10 deletions include/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -756,17 +756,23 @@ static void setup_form(char *buffer, char *templn)
cellFsClose(fd);
sprintf(templn, "&nbsp; &nbsp;" HTML_INPUT("ccbo\" list=\"cmds", "%s", "255", "50") "<br>", command); strcat(buffer, templn);

strcat(buffer, "<div style=\"display:none\"><datalist id=\"cmds\">");
strcat(buffer, "<option>GET /browser.ps3$block_servers</option>");
strcat(buffer, "<option>GET /browser.ps3$disable_syscalls?keep_ccapi</option>");
#ifdef XMB_SCREENSHOT
strcat(buffer, "<option>GET /browser.ps3$screenshot_xmb</option>");
#endif
strcat(buffer, "<option>GET /cpursx.ps3?mode</option>");
strcat(buffer, "<option>GET /klic.ps3?log</option>");
strcat(buffer, "</datalist></div>");
}
strcat(buffer, "<div style=\"display:none\"><datalist id=\"cmds\">"
#ifdef PS3_BROWSER
"<option>GET /browser.ps3$block_servers</option>"
#ifdef REMOVE_SYSCALLS
"<option>GET /browser.ps3$disable_syscalls?keep_ccapi</option>"
#endif
#ifdef XMB_SCREENSHOT
"<option>GET /browser.ps3$screenshot_xmb</option>"
#endif
#endif
"<option>GET /cpursx.ps3?mode</option>"
#ifdef GET_KLICENSEE
"<option>GET /klic.ps3?log</option>"
#endif
"</datalist></div>");
}
#endif // #ifdef WM_REQUEST

sprintf(templn, HTML_RED_SEPARATOR "<input type=\"submit\" value=\" %s \"/>"
"</form>", STR_SAVE); strcat(buffer, templn);
Expand Down
Loading

0 comments on commit 9b89c75

Please sign in to comment.