rejetto forum
Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: SpiderPig902 on May 24, 2010, 03:10:17 PM
-
Hi, im back to finish my admin template and am stuck on something. Im trying to make the username list a drop down list. Like in my html i have this:
<select name="username">username
<option title="option" value="">{.get|accounts.}
</option>
</select>
This just make a list of the name and instead i need to create a drop down list so that i can shoose the specific name i want.
Can someone help with this? Im stuck.
Thanks
SP
-
Yes it is possible by using this part of admin template, but some macros have to be replaced by their equivalent in the wiki
the magic macro used here is {.get|accounts|users.}
create a group named #adminpanel# and set account members of this group which are allowed to access the panel admin
url: http://127.0.0.1/~passchanger
[passchanger]
{.if||{.get account|%user%|member of|#adminpanel#.}|
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="/~style.css" type="text/css">
<style fprolloverstyle>A:hover {color:#b30000; font-style: italic;}
</style>
<br/>
<title>{.!Pass Changer.}</title>
<div id='body'>
<img src="/~img27"><font size="3" color=555"> {.!Welcome.} %user% !</font size>
<br/><hr color=555"> </b>
<br/>
- {.!To use this function, simply select an.} <b>{.!User Account.}</b> {.!in the.} <FONT COLOR=firebrick><b>{.!list.}</b></FONT>.<p>
- {.!Enter the.} <b>{.!Current Password.}</b> {.!of that.} <b>{.!User.}</b>.<p>
- {.!Then type the new password for that User..}<p>
- {.!Click on.} <FONT COLOR=firebrick><b>{.!Change.}</b></FONT>.
<br/>
<br/>
<p>
<form name='usersform' method='post' action='/~passchanger'>
<select name="usersname" onchange=submit()>
<option value="">{.!Select an User Account.}</option>
</select>
<!--- this script is here to generate the list of accounts--->
<script type="text/JavaScript">
var liste='{.if|{.get account|%user%|member of|#adminpanel#.}|{.get|accounts|users.}.}';
var reg=new RegExp("[;]+", "g");
var tableau=liste.split(reg);
for (var i=tableau.length-1; i>=0; i--) {
var objtselect = document.forms.usersform.usersname;
var dmc = document.createElement("option");
dmc.text = tableau[i] ;
dmc.value = tableau[i];
if(!document.all){
before= objtselect.options[1];
}else{
before=1;
}
if( dmc.text != '%user%') objtselect.add(dmc,before);
document.forms.usersform.usersname.value='{.postvar|usersname.}';
}
</script>
</form>
<br/>
<form method=post action="/~passchange">
<table>
<tr><td align=left><b><font size="4"><font size="4">{.!Username.}</font></b></font></b><td><b><font size="4"><font color=darkgreen> {.postvar|usersname.}</font></b><input type="hidden" name="name" value="{.postvar|usersname.}" style="font-size:10pt; font-weight:bold; color:7F7F7F; background-color:FFFFFF; border:3px solid #AB9F82;" size="{.!25.}">
<tr><td align=left><b><font size="4"><font size="4">{.!Current Password.}</font></b></font></b><td><b><font size="4"> </font></b><span style="background-color: #000000"><input name="oldpass" style="font-size:10pt; font-weight:bold; color:7F7F7F; background-color:FFFFFF; border:3px solid #AB9F82;" size="{.!25.}" ></span>
<tr><td align=left><b><font size="4"><font size="4">{.!New Password.}</font></b></font></b><td><b><font size="4"> </font></b><span style="background-color: #000000"><input name="newpass" style="font-size:10pt; font-weight:bold; color:7F7F7F; background-color:FFFFFF; border:3px solid #AB9F82;" size="{.!25.}" ></span>
<tr><td align=left><font size="4"><td align=center><br/><input type=submit value="{.!Change.}"></font>
</tr></table>
<br/>
<hr color=555">
<center><a href="/~adminpanel">{.!1Home|Administration Panel.} </a></p></center>
<center><a href="/">{.!Home.}</a></p></center>
</form>
</body>
</html>
|{.section|error.}.}
[passchange]
{.if|{.get account|%user%|member of|#adminpanel#.}|
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="/~style.css" type="text/css">
<style fprolloverstyle>A:hover {color:#b30000; font-style: italic;}
</style>
<br/>
<title>{.!Pass Changer.}</title>
</head>
<div id='body'>
{.if|{.get account|{.postvar|name.}|password is|{.postvar|oldpass.}.}|{:{.set account|{.postvar|name.}|password={.postvar|newpass.}.}:}/if.}
<img src="/~img27"><font size="3" color=555"> %user% </font>
<br/>
<hr color=555">
<br/>
<p><font size="4">{.if|{.get account|{.postvar|name.}|password is|{.postvar|newpass.}.}|{.!Password changed !.}|<font color=firebrick>{.!Error during change !.}/if.}</font></p>
<br/>
<hr color=555">
<center><a href="/~adminpanel">{.!1Home|Administration Panel.}</a></p></center>
<center><a href="/">{.!Home.}</a></p></center>
</form>
</body>
</html>
|{.section|error.}.}
[error]
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="/~style.css" type="text/css">
<style fprolloverstyle>A:hover {color:#b30000; font-style: italic;}
</style>
<br/>
<title>{.!Error.}</title>
</head>
<body>
<div id='body'>
<img src="/~img11">
<br/>
<hr color=555">
<br/>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"><font size="6" color="#555"><b>{.!You do not have sufficient privileges to access this feature..}</b></font></p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"><font size="6" color="#555"><b>{.!You must be an administrator..}</b></font></p>
<br/>
<br/>
<br/>
<hr color=555">
<center><a href="/">{.!Home.}</a></p></center>
</body>
</html>
-
hi, that looks awesome. is this from a template that i can get?
also, i cant get the adminpanel group security access to work. i created a group and added myself to it and still says i dont have access.
Another problem is when i use the drop down box and choose a name, the screen refreshes and then just goes back to default saying Choose a Name. Is there other java script in the beginning of the script or something?
Thanks again this will be awesome when i get it working.
SP
-
Another problem is when i use the drop down box and choose a name, the screen refreshes and then just goes back to default saying Choose a Name.
the code works perfectly, the screen refreshes because the name of selected account is refresh as on attached images
the Pass Changer use two forms
one to send to himself the selection
the second to valid change of password
you can use this new update (no refresh needed) passchanger new view.png (http://www.rejetto.com/forum/index.php?action=dlattach;topic=8605.0;attach=5294)
[passchanger]
{.if||{.get account|%user%|member of|#adminpanel#.}|
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="/~style.css" type="text/css">
<style fprolloverstyle>A:hover {color:#b30000; font-style: italic;}
</style>
<br/>
<title>{.!Pass Changer.}</title>
<div id='body'>
<img src="/~img27"><font size="3" color=555"> {.!Welcome.} %user% !</font size>
<br/><hr color=555"> </b>
<br/>
- {.!To use this function, simply select an.} <b>{.!User Account.}</b> {.!in the.} <FONT COLOR=firebrick><b>{.!list.}</b></FONT>.<p>
- {.!Enter the.} <b>{.!Current Password.}</b> {.!of that.} <b>{.!User.}</b>.<p>
- {.!Then type the new password for that User..}<p>
- {.!Click on.} <FONT COLOR=firebrick><b>{.!Change.}</b></FONT>.
<br/>
<br/>
<p>
<br/>
<form name='usersform' method=post action="/~passchange">
<table>
<tr><td align=left><b><font size="4"><font size="4">{.!Username.}</font></b></font></b><td><b><font size="4"><font color=darkgreen> </font></b>
<select name="username">
<option value="">{.!Select an User Account.}</option>
</select>
<script type="text/JavaScript">
var liste='{.if|{.get account|%user%|member of|#adminpanel#.}|{.get|accounts|users.}.}';
var reg=new RegExp("[;]+", "g");
var tableau=liste.split(reg);
for (var i=tableau.length-1; i>=0; i--) {
var objtselect = document.forms.usersform.username;
var dmc = document.createElement("option");
dmc.text = tableau[i] ;
dmc.value = tableau[i];
if(!document.all){
before= objtselect.options[1];
}else{
before=1;
}
if( dmc.text != '%user%') objtselect.add(dmc,before);
}
</script>
<tr><td align=left><b><font size="4"><font size="4">{.!Current Password.}</font></b></font></b><td><b><font size="4"> </font></b><span style="background-color: #000000"><input name="oldpass" style="font-size:10pt; font-weight:bold; color:7F7F7F; background-color:FFFFFF; border:3px solid #AB9F82;" size="{.!25.}" ></span>
<tr><td align=left><b><font size="4"><font size="4">{.!New Password.}</font></b></font></b><td><b><font size="4"> </font></b><span style="background-color: #000000"><input name="newpass" style="font-size:10pt; font-weight:bold; color:7F7F7F; background-color:FFFFFF; border:3px solid #AB9F82;" size="{.!25.}" ></span>
<tr><td align=left><font size="4"><td align=center><br/><input type=submit value="{.!Change.}"></font>
</tr></table>
<br/>
<hr color=555">
<center><a href="/~passchanger">{.!1Home|Administration Panel.} </a></p></center>
<center><a href="/">{.!Home.}</a></p></center>
</form>
</body>
</html>
|{.section|error.}.}
[passchange]
{.if|{.get account|%user%|member of|#adminpanel#.}|
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="/~style.css" type="text/css">
<style fprolloverstyle>A:hover {color:#b30000; font-style: italic;}
</style>
<br/>
<title>{.!Pass Changer.}</title>
</head>
<div id='body'>
{.if|{.get account|{.postvar|username.}|password is|{.postvar|oldpass.}.}|{:{.set account|{.postvar|username.}|password={.postvar|newpass.}.}:}/if.}
<img src="/~img27"><font size="3" color=555"> %user% </font>
<br/>
<hr color=555">
<br/>
<p><font size="4">{.if|{.get account|{.postvar|username.}|password is|{.postvar|newpass.}.}|{.!Password changed !.}|<font color=firebrick>{.!Error during change !.}/if.}</font></p>
<br/>
<hr color=555">
<center><a href="/~passchanger">{.!1Home|Administration Panel.}</a></p></center>
<center><a href="/">{.!Home.}</a></p></center>
</form>
</body>
</html>
|{.section|error.}.}
[error]
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" href="/~style.css" type="text/css">
<style fprolloverstyle>A:hover {color:#b30000; font-style: italic;}
</style>
<br/>
<title>{.!Error.}</title>
</head>
<body>
<div id='body'>
<img src="/~img11">
<br/>
<hr color=555">
<br/>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"><font size="6" color="#555"><b>{.!You do not have sufficient privileges to access this feature..}</b></font></p>
<p align="center"> </p>
<p align="center"> </p>
<p align="center"><font size="6" color="#555"><b>{.!You must be an administrator..}</b></font></p>
<br/>
<br/>
<br/>
<hr color=555">
<center><a href="/">{.!Home.}</a></p></center>
</body>
</html>
-
thank you.
In your instruction you say to create a group called #adminpanel#, do you mean WITH the pound signs or without?
Thanks
-
In your instruction you say to create a group called #adminpanel#,
it is a security to restrict access to only some accounts
you can rename it as you choice, but you have change in the code all text found as
{.get account|%user%|member of|#adminpanel#.}
or change all this macro by (3 items to change)
{.=|%user%|admin.} where admin is your account as admin (not a group)
-
Thank you very much, this has helped alot..
Could you help me with another problem i copied off of your code. Im trying to use your javascript for the drop downs and im on the "StatisChanger".
This is what i have:
{.if|{.get account|%user%|member of|#administrators#.}|
{.set account|{.postvar|name.}|enabled={.postvar|status.}.}
<p><font size="3">
{.if|{.get account|{.postvar|name.}|enabled is|{.postvar|status.}.}|{.!Status Changed !.}|<font color=firebrick>{.!Error during change !.}/if.}</font></font></p>
{.postvar|name.}-{.postvar|status.}
<p>Click <a href="/~adminpanel">here</a> to return.</p>
|{.section|error.}.}
Everytime i change the status, it works, but this line always shows "Error during change".
Can you see what im doing wrong?
What script did you use for your java or did you write it all yourself?
Thanks
-
I noted a mistake: you have only to remove the red text.
{.if|{.get account|%user%|member of|#administrators#.}
|{.set account|{.postvar|name.}|enabled={.postvar|status.}.}
<p><font size="3">
{.if|{.get account|{.postvar|name.}|enabled is|{.postvar|status.}.}
|{.!Status Changed !.}
|<font color=firebrick>{.!Error during change !.}</font>
/if.}
</font></p>
{.postvar|name.}-{.postvar|status.}
<p>Click <a href="/~adminpanel">here</a> to return.</p>
|{.section|error.}
/if.}
{.get account | A | B.}
expands to the value of property B of account A.
Supported value for B are redirect, no limits, enabled, is group, member of, notes, notes key
one exception:
{.get account | A | member of | B.} B is Group names for member of are semicolon-separated.
example: {.get account|%user%|member of|#administrators#;admingroup;.}
help at http://www.rejetto.com/wiki/index.php/HFS:_scripting_commands
It should work with no problem at all, good luck ;)
-
Thanks for the update. that kinda worked but kinda didnt. If i enable an account it works but if i disable an account it says it failed even though it actually did work. Thats why i tried to see if it matched the "{.postvar|status.}" that was chosen in the form.
-
{.if|{.get account|%user%|member of|#administrators#.}
|{.set account|{.postvar|name.}|enabled={.postvar|status.}.}
<p><font size="3">
{.if|{.get account|{.postvar|name.}|enabled.}
|{.!Status Changed !.}
|<font color=firebrick>{.!Error during change !.}</font>
/if.}
</font></p>
{.postvar|name.} - Account is actualy {.if|{.get account|{.postvar|name.}|enabled.}|Enabled|Disabled.}
<p>Click <a href="/~adminpanel">here</a> to return.</p>
|{.section|error.}
/if.}
-
ok think i finally got it. its all working, Thank you very much.
I have i hope one last question, when i dont choose a username and just click 'Change" on any of the code, it by default selects the account im logged in with. Is there a way to say something like "if {.postvar|name.}|""|Error" or something like that. so if a name from the drop down list is not chosen, that it wont run the script?
Thanks again.
-
{.if|{.get account|%user%|member of|#administrators#.}
|{.if|{.postvar|name.}
|{.set account|{.postvar|name.}|enabled={.postvar|status.}.}
<p><font size="3">
{.if|{.get account|{.postvar|name.}|enabled.}
|{.!Status Changed !.}
|<font color=firebrick>{.!Error during change !.}</font>
/if.}
</font></p>
{.postvar|name.} - Account is actualy {.if|{.get account|{.postvar|name.}|enabled.}|Enabled|Disabled.}
|You have to select an account before sending form
/if.}
<p>Click <a href="/~adminpanel">here</a> to return.</p>
|{.section|error.}
/if.}
when {.postvar|name.} is empty then the macro {.set account||enabled= .} was taken the current user by default
;)
-
awesome. thank you so much. i will share my modifications to the terayon theme when its complete.
SP