jueves, 19 de julio de 2012

Calculadora de permisos


Una calculadora de permisos en Linux, copien y peguen el codigo, luego guardenlo con el nombre que quieran   pero con extencion .html
ej  calculadorachamod.html


<html>
<head>
<script language="JavaScript">
<!--

function disableselect(e){
  return false
}

function reEnable(){
  return true
}

document.onselectstart = new Function ("return false");

if (window.sidebar){
  document.onmousedown=disableselect
  document.onclick=reEnable
}

// Script
// Variables
var box;
var a;
var b;

// Function
function calc(user, number) {
  // Owner
  if (user == 'owner' && number == '4') box = eval("document.all.chmod.owner4");
  if (user == 'owner' && number == '2') box = eval("document.all.chmod.owner2");
  if (user == 'owner' && number == '1') box = eval("document.all.chmod.owner1");

  // Group
  if (user == 'group' && number == '4') box = eval("document.all.chmod.group4");
  if (user == 'group' && number == '2') box = eval("document.all.chmod.group2");
  if (user == 'group' && number == '1') box = eval("document.all.chmod.group1");

  // Other
  if (user == 'other' && number == '4') box = eval("document.all.chmod.other4");
  if (user == 'other' && number == '2') box = eval("document.all.chmod.other2");
  if (user == 'other' && number == '1') box = eval("document.all.chmod.other1");

  if (box.checked == true) {
    // Owner
    if (user == 'owner') {
      document.chmod.h_owner.value += ' + number';
      a = document.all.chmod.h_owner.value;
      b= eval(a);
      document.all.chmod.h_owner.value=b;
      document.all.chmod.t_owner.value=b;
    }
    // Group
    if (user == 'group') {
      document.all.chmod.h_group.value += ' + number';
      a= document.all.chmod.h_group.value;
      b= eval(a);
      document.all.chmod.h_group.value = b;
      document.all.chmod.t_group.value = b;
    }
    // Other
    if (user == 'other') {
      document.chmod.h_other.value += ' + number';
      a= document.all.chmod.h_other.value;
      b= eval(a);
      document.all.chmod.h_other.value = b;
      document.all.chmod.t_other.value = b;
    }
  }

  if (box.checked == false) {
    // Owner
    if (user == 'owner') {
      if (document.all.chmod.h_owner.value == '') {
document.all.chmod.t_owner.value=""
      } else {
a = document.all.chmod.h_owner.value;
        b = a - number;
c = eval(b);
document.all.chmod.h_owner.value = c;
document.all.chmod.t_owner.value = c;
      }
    }
    // Group
    if (user == 'group') {
      if (document.all.chmod.h_group.value == '') {
document.all.chmod.t_group.value="";
      }else {
a = document.all.chmod.h_group.value;
b = a - number;
c = eval(b);
document.all.chmod.h_group.value=c;
document.all.chmod.t_group.value=c;
      }
    }
    // Other
    if (user == 'other') {
      if (document.all.chmod.h_other.value == '') {
document.all.chmod.t_other.value=""
      } else {
a = document.all.chmod.h_other.value;
b = a - number;
c = eval(b);
document.all.chmod.h_other.value=c;
document.all.chmod.t_other.value=c;
      }
    }
  }
}

//-->
</script>

<div align="center">
<form name="chmod">
  <input name="h_owner" type="hidden" value="">
  <input name="h_group" type="hidden" value="">
  <input name="h_other" type="hidden" value="">
  <table bgcolor="#000000" cellpadding="5" cellspacing="1">
    <tr bgcolor="#ffffff" align="center">
      <td colspan="4"><b>Calculadora CHMOD</b></td>
    </tr>
    <tr bgcolor="#ffffff" align="center">
      <td><b>Permisos</b></td>
      <td><b>Owner</b></td>
      <td><b>Group</b></td>
      <td><b>Other</b></td>
    </tr>
    <tr bgcolor="#ffffff" align="center">
      <td><b>Leer</b> (4)</td>
      <td><input type="checkbox" name="owner4" value="4" onclick="calc('owner', 4)"></td>
      <td><input type="checkbox" name="group4" value="4" onclick="calc('group', 4)"></td>
      <td><input type="checkbox" name="other4" value="4" onclick="calc('other', 4)"></td>
    </tr>
    <tr bgcolor="#ffffff" align="center">
      <td><b>Escribir</b> (2)</td>
      <td><input type="checkbox" name="owner2" value="2" onclick="calc('owner', 2)"></td>
      <td><input type="checkbox" name="group2" value="2" onclick="calc('group', 2)"></td>
      <td><input type="checkbox" name="other2" value="2" onclick="calc('other', 2)"></td>
    </tr>
    <tr bgcolor="#ffffff" align="center">
      <td><b>Ejecutar</b> (1)</td>
      <td><input type="checkbox" name="owner1" value="1" onclick="calc('owner', 1)"></td>
      <td><input type="checkbox" name="group1" value="1" onclick="calc('group', 1)"></td>
      <td><input type="checkbox" name="other1" value="1" onclick="calc('other', 1)"></td>
    </tr>
    <tr bgcolor="#ffffff" align="center">
      <td><b>Valor</b></td>
      <td><input type="text" name="t_owner" value="0" size="1" READONLY onFocus="this.blur()"></td>
      <td><input type="text" name="t_group" value="0" size="1" READONLY onFocus="this.blur()"></td>
      <td><input type="text" name="t_other" value="0" size="1" READONLY onFocus="this.blur()"></td>
    </tr>
  </table>
</form>
</div>
</center>
</body>
</html>

No hay comentarios:

Publicar un comentario