Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: Ребятки, оч срочно помогите прочитать рабочий код!!!
Форумы портала PHP.SU » Клиентская разработка » JavaScript & VBScript » Ребятки, оч срочно помогите прочитать рабочий код!!!

Страниц (1): [1]
 

1. Virus1850 - 19 Ноября, 2016 - 14:35:04 - перейти к сообщению
Ребят, есть рабочий готовый код, с проверочным полем, т.е. из текста рандомно выбираются буквы и выделяются серымцветом, эти буквы смещаются (судя по коду на 3 шага) и есть проверочное поле, в который нужно вбить декодированный код, если они совпадают - отображается сообщение о верности кода. Если нет, то нет. Но я в упор не могу понять порядок букв, кто может прочитать код и сказать в каком порядке рандомно выбранные буквы проходят через скрипт Цезаря??? и соответственно как сформировать правильный код.
Просто если брать буквы с лева на право, потом смещать из на 3 шага по Цезарю то код не верен((
CODE (javascript):
скопировать код в буфер обмена
  1.  
  2. // <![CDATA[
  3. var user = $("#tblUserBox").find('td:first').children('a');
  4. var game;
  5. var useringame = false;
  6. $("#lnkGameTitle").each(function(){
  7.     if ($(this).html()=="Abstergo Recruting Center")
  8.     {
  9.         game = $(this).parents('.gameInfo');
  10.     }
  11. });
  12.  
  13. game.find("#lnkPlayerInfo").each(function(){
  14.     $.post($(this).attr('href'), function(data){
  15.         var team = $(data).find("#tdContentCenter");
  16.         if (team.find('#lnkCaptainInfo').html() == user.html())
  17.         {
  18.             useringame = true;
  19.         }
  20.         else
  21.         {
  22.             team.find('#lnkLogin').each(function(){
  23.                 if ($(this).html() == user.html())
  24.                 {
  25.                     useringame = true;
  26.                 }
  27.             });
  28.         }
  29.     });
  30. });
  31. game.find("#lnkAuthor").each(function(){
  32.     if ($(this).html() == user.html())
  33.                 {
  34.                     useringame = true;
  35.                 }
  36. });
  37. game.children('tbody').children("tr:nth-child(4)").find('a').each(function(){
  38.     if ($(this).html() == user.html())
  39.                 {
  40.                     useringame = true;
  41.                 }
  42. });
  43.  
  44.     setTimeout(function(){
  45.         $("#loading").fadeOut(1000);
  46.     setTimeout(function(){
  47.         $("#an-body").fadeIn();
  48.     },1000);
  49.     }, 3500);
  50.  
  51.     $("#an-menu div").on("mouseenter", function(){
  52.  
  53.     if (!$(this).hasClass("active"))
  54.     {
  55.         $(this).css("background","white").css("color","black");
  56.     }
  57.     });
  58.     $("#an-menu div").on("mouseout", function(){
  59.     if (!$(this).hasClass("active"))
  60.     {
  61.         $(this).css("background","none").css("color","white");
  62.     }
  63.     });
  64.     $("#an-menu div").on("click", function(){
  65.     if (!$(this).hasClass("active"))
  66.     {
  67.         $("#an-menu div").css("background","none").css("color","white");
  68.         $("#an-menu div").removeClass("active");
  69.         $(this).css("background","white").css("color","black");
  70.         var cl = $(this).attr("class");
  71.         $(this).addClass("active");
  72.         $(".menu-body .toggled").css("display","none");
  73.         $(".menu-body .toggled."+cl).fadeToggle(400);
  74.     }
  75.     });
  76.  
  77.     function getRandomInt(min, max)
  78.     {
  79.     return Math.floor(Math.random() * (max - min + 1)) + min;
  80.     }
  81.  
  82.     function containsObject(obj, list) {
  83.         var i;
  84.         for (i = 0; i < list.length; i++) {
  85.                 if (list[i] === obj) {
  86.                         return true;
  87.                 }
  88.         }
  89.         return false;
  90.     }
  91.  
  92.     function randomChar(){
  93.     var pool = "абвгдежзийклмнопрстуфхцчшщъыьэюя";
  94.         var arr = pool.split('');
  95.         return arr[Math.floor(Math.random()*arr.length)];
  96.     }
  97.  
  98.     var passlenght = Math.floor(Math.random()+5.75);
  99.     var ppwd = [];
  100.  
  101.     for (var i=0;i<passlenght;i++)
  102.     {
  103.         var ch = randomChar();
  104.         if (i < 3)
  105.         {
  106.             html = $(".menu-body .about span").html();
  107.             while(html.search(ch)==-1)
  108.             {
  109.                 ch = randomChar();
  110.             }
  111.             ppwd.push(ch);
  112.             $(".menu-body .about span").html(html.replace(ch,'-'+i+'-'));
  113.         }
  114.         else
  115.         if (i< 5)
  116.         {
  117.             html = $(".menu-body .req span").html();
  118.             while(html.search(ch)==-1)
  119.             {
  120.                 ch = randomChar();
  121.             }
  122.             ppwd.push(ch);
  123.             $(".menu-body .req span").html(html.replace(ch,'-'+i+'-'));
  124.         }
  125.         else
  126.         {
  127.             html = $(".menu-body .addit span").html();
  128.             while(html.search(ch)==-1)
  129.             {
  130.                 ch = randomChar();
  131.             }
  132.             ppwd.push(ch);
  133.             $(".menu-body .addit span").html(html.replace(ch,'-'+i+'-'));
  134.         }
  135.     }
  136.  
  137.     for (var i=0;i<passlenght;i++)
  138.     {
  139.         var ch = randomChar();
  140.         if (i < 3)
  141.         {
  142.             html = $(".menu-body .about span").html();
  143.             $(".menu-body .about span").html(html.replace('-'+i+'-','<span style="color:#c0c0c0" title="'+(i+1)+'">'+ppwd[i]+'</span>'));
  144.         }
  145.         else
  146.         if (i< 5)
  147.         {
  148.             html = $(".menu-body .req span").html();
  149.             $(".menu-body .req span").html(html.replace('-'+i+'-','<span style="color:#c0c0c0" title="'+(i+1)+'">'+ppwd[i]+'</span>'));
  150.         }
  151.         else
  152.         {
  153.             html = $(".menu-body .addit span").html();
  154.             $(".menu-body .addit span").html(html.replace('-'+i+'-','<span style="color:#c0c0c0" title="'+(i+1)+'">'+ppwd[i]+'</span>'));
  155.         }
  156.     }
  157.  
  158.     var Cesar = new
  159.     (function Cesar(offset){
  160.         var ACode = "а".charCodeAt(0), alphabetSize = 32, Self = this;
  161.         this.encodeChar = function(ch){return (ch+offset-ACode+alphabetSize)%alphabetSize + ACode; };
  162.         this.decodeChar = function(ch){return (ch-offset-ACode+alphabetSize)%alphabetSize + ACode; };
  163.         this.encode =
  164.                 function(str){ var res="", chr;
  165.                         for(var a=0;a<str.length;++a)
  166.                                 if((chr=str.charCodeAt(a)) && (chr>=ACode) && (chr-ACode<alphabetSize))
  167.                                         res+=String.fromCharCode(Self.encodeChar(chr));
  168.                                 else res+=str.charAt(a);
  169.                         return res;
  170.                 };
  171.         this.decode =
  172.                 function(str){ var res="";
  173.                         for(var a=0;a<str.length;++a)
  174.                                 if((chr=str.charCodeAt(a)) && (chr>=ACode) && (chr-ACode<alphabetSize))
  175.                                         res+=String.fromCharCode(Self.decodeChar(chr));
  176.                                 else res+=str.charAt(a);
  177.                         return res;
  178.                 };
  179.     })(3);
  180.  
  181.     var thisisit = Cesar.encode(ppwd.join(''));
  182.     function handle(e){
  183.                 if(e.keyCode === 13){
  184.         $("#password").next('p').remove();
  185.         $("#password").css("border-color","white");
  186.             if($("#password").val()==thisisit)
  187.             {
  188.                 $('.code').fadeToggle(1000);
  189.                 setTimeout(function() {
  190.                     $('.code').html("<span style='font-size: 18px'>Поздравляем, Код верный!</span>");
  191.                     $('.code').css("width","60%");
  192.                     var lnk = $('span.aqua.padL3');
  193.                     lnk.html('900рэ (скидка 200р!)');
  194.                     lnk.next().html('Ваш персональный код - '+thisisit+'. Шифр - '+ppwd.join('')+'.');
  195.                     $('.code').fadeToggle(1000);
  196.                 }, 1500);
  197.             }
  198.             else
  199.             {
  200.                 $("#password").css("border-color","red");
  201.                 $("#password").after('<p style="margin-top:10px;">Неверный код</p>')
  202.             }
  203.         }
  204.         }
  205. // ]]>
  206.  

 

Powered by ExBB FM 1.0 RC1