Advertisement
Guest User

climbo

a guest
Jul 28th, 2009
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script language="javascript" type="text/javascript">
  2. //CONTADOR PERSONAL
  3. //  by Mauricio Alejandro
  4. //
  5. //Este script y otros muchos pueden
  6. //descarse on-line de forma gratuita
  7. //en El Código: www.elcodigo.com
  8.  
  9.  
  10. function chequeo() {
  11.   if (!confirm("Hola, este es tu contador personal."))
  12.   history.go(-1);
  13.   return ""
  14. }
  15.  
  16. //establece valor cookie
  17. function galletita (nombre, valor) {
  18.   var argumentosA = galletita.arguments
  19.   var argumentosB = galletita.arguments.length
  20.   var expires = (argumentosB > 2) ? argumentosA[2] : null
  21.   var control = (argumentosB > 3) ?argumentosA[3] : null
  22.   var dominio = (argumentosB > 4) ? argumentosA[4] : null
  23.   var broche = (argumentosB > 5) ? argumentosA[5] : false
  24.   document.cookie = nombre + "=" + escape (valor) +
  25.     ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  26.     ((control == null) ? "" : ("; control=" + control)) +
  27.     ((dominio == null) ? "" : ("; dominio=" + dominio)) +
  28.     ((broche == true) ? "; broche" : "")
  29. }
  30.  
  31. //obtencion valor cookie
  32. function galletavaluada(cepilo) {
  33.   var fin = document.cookie.indexOf (";", cepilo)
  34.   if (fin == -1) fin = document.cookie.length
  35.   return unescape (document.cookie.substring(cepilo, fin))
  36. }
  37.  
  38. function galleta(nombre) {
  39.   var A1 = nombre+"="
  40.   var A2 = A1.length
  41.   var A3 = document.cookie.length
  42.   var i = 0
  43.   while (i < A3) {
  44.     var j = i + A2
  45.     if (document.cookie.substring(i, j) == A1) return galletavaluada(j)
  46.     i = document.cookie.indexOf(" ", i) + 1
  47.     if (i == 0) break
  48.   }
  49.   return null
  50. }
  51.  
  52. //obtencion de datos
  53. var apodo=galleta("msg1")
  54. if (apodo== null) {
  55.   document.writeln(chequeo())
  56.   var apodo=prompt('Por favor, escribe tu apodo:','')
  57.   var caducar = new Date ();
  58.   caducar.setTime (caducar.getTime() + (24 * 60 * 60 * 1000 * 365))
  59.   galletita ("msg1", apodo, caducar)
  60. }
  61.  
  62. //contadores
  63. function contador(contar) {
  64.   var contador=galleta("msg2")
  65.   if (contar==0) { contar=1 }
  66.   else contador++
  67.   var caducar = new Date ()
  68.   caducar.setTime (caducar.getTime() + (24 * 60 * 60 * 1000 * 365))
  69.   galletita ("msg2", contador, caducar)
  70.   return (contador)
  71. }
  72.  
  73. var acceso=contador("contar")
  74.  
  75. //escribe niveles de usuario
  76. function infousuario() {
  77.   if (acceso >= 30) {document.write('Supervisitante') }
  78.   else if (acceso >= 20) {document.write('Adicto') }
  79.   else if (acceso >= 10) {document.write('Experimentado') }
  80.   else if (acceso >= 5) {document.write('Regular') }
  81.   else {document.write('Amateur') }
  82. }
  83.  
  84. function enviar(nombre, contenido, expires) {
  85.   document.cookie = nombre + "=" + escape(contenido) + ((expires == null) ? "" : ("; expires=" + expires.toGMTString()))
  86. }
  87.  
  88. function recibir(nombre) {
  89.   galleta = nombre + "="
  90.   if (document.cookie.length > 0) {
  91.     principio = document.cookie.indexOf(galleta)
  92.     if (principio != -1) {
  93.       principio += galleta.length
  94.       fin = document.cookie.indexOf(";", principio)
  95.       if (fin == -1)
  96.         fin = document.cookie.length
  97.       return unescape(document.cookie.substring(principio, fin))
  98.     }
  99.   }
  100. }
  101.  
  102. //comprueba y escribe fecha ultima visita
  103. function ultimavisita() {
  104.   fecha = new Date()
  105.   mes = fecha.getMonth() + 1
  106.   fechas = fecha.getDate() + "/" + mes + "/" + fecha.getFullYear()
  107.   expires = new Date(2001, 12, 31)
  108.   ultima = recibir("visita")
  109.   if(!ultima) {
  110.     enviar("visita", fechas, expires)
  111.     document.write("1ª visita")
  112.   }
  113.   else {
  114.     document.write(ultima)
  115.     enviar("visita", fechas, expires)
  116.   }
  117. }
  118.  
  119.  
  120.  
  121.  
  122. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement