Pokazywanie postów oznaczonych etykietą javascript. Pokaż wszystkie posty
Pokazywanie postów oznaczonych etykietą javascript. Pokaż wszystkie posty

wtorek, 18 lutego 2014

JS:Clickjack-A [Trj], JS/Agent.NKW trojan na stronie - Rozwiązanie

Ten Trojan dołącza się zazwyczaj do pliku php, jako skrypt js
U mnie wystąpił w templetce modułu joomla inowslider.
Usunięcie:

1. Otwórz \modules\mod_inowslider\tmpl\default.php

2. Poszuka i usuń skrypt wyglądający mniej więcej tak :
<script language="JavaScript">
function dnnViewState()
{
var a=0,m,v,t,z,x=new Array('xxxxxx'),l=x.length;while(++a<=l){m=x[l-a];
t=z='';
for(v=0;v<m.length;){t+=m.charAt(v++);
if(t.length==2){z+=String.fromCharCode(parseInt(t)+25-l+a);
t='';}}x[l-a]=z;}document.write('<'+x[0]+' '+x[4]+'>.'+x[2]+'{'+x[1]+'}</'+x[0]+'>');}dnnViewState();
</script> 


3.Na końcu pliku zlokalizuj i usuń ten kod.
<p class="dnn">By A <a href="http://www.autson.com/" title="web design company">Web Design</a></p>

4.Po zapisaniu usunąłeś trojana z modułu, możesz jeszcze przeskanować plik dla pewności antywirusem np: Avastem, Nodem

środa, 4 stycznia 2012

Domyślny parametr funkcji

Czasami zachodzi potrzeba ustawienie domyślnego parametru przekazywanego funkcji

Aby to wykonać należy sprawdzić czy parametr został zdefiniowany przy przekazaniu np:

function ShowSelected(bCategory)
{
   bCategory = typeof(bCategory) != 'undefined' ? bCategory : true;
...
}

w tym przypadku domyślny parametr jest typu bool i jeżeli nie został przekazany to domyślną wartością jest true;

poniedziałek, 4 kwietnia 2011

JavaScript jak sprawdzić czy funkcja istnieje

W JavaScript można wykonać to przynajmniej na 2 sposoby:

if(typeof (window.myFunction) == ‘function’) {
// funkcja istnieje więc możemy ją wywołać
myFunction(’foo’, ‘bar’);
}


lub nawet prościej

if(myFunction) { //funkcja istnieje
myFunction(‘foo’, ‘bar’);
}

środa, 4 listopada 2009

Detekcja przeglądarki IE - wersja rozszerzona

Jest to rozszerzona funkcja IsIE(), która dodatkowo może sprawdzić czy przeglądarka jest w wersji 8/7/6.
Wywołanie:
IsIE() - czy to przeglądarka IE
IsIE(6) - czy to IE6, IE6+ ale nie 7,8
IsIE(7) - czy to IE7, IE7+ ale nie 8
IsIE(8) - czy to IE8, IE8+
function IsIE(nVer)
{
    if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
        if (nVer == null) {
            return true;
        }
        else {
            var ieversion = new Number(RegExp.$1) 
            if ((ieversion >= 8)&&(nVer==8)) return true;
            else if ((ieversion >= 7)&&(nVer==7)) return true;                
            else if ((ieversion >= 6)&&(nVer==6)) return true;
            else return false;
        }
    }
}

wtorek, 3 listopada 2009

Prosty SlideShow w znaczniku DIV włącznie z rysunkami typu png

W body html znacznik div z ID
<div class="klasa" ID="slideshow"></div>
oraz przy znaczniku body
<body onload="show('pic',5);" >
ustawienie co 5 sek zmiany wyświetlanych obrazów

Kod javascript
var nPic = 0;

var tab_pic = new Array(7);
    tab_pic[0]="pic/pic1.jpg";
    tab_pic[1]="pic/pic2.jpg";
    tab_pic[2]="pic/pic3.jpg";
    tab_pic[3]="pic/pic4.jpg";
    tab_pic[4]="pic/pic5.jpg";
    tab_pic[5]="pic/pic6.jpg";   
    tab_pic[6]="pic/pic7.png";   



function show(nId,nSec){
  window.setInterval('nPic = slideshow("'+nId+'",nPic)',(nSec*1000));
}

function slideshow(nId,nPic)
{
    if (document.getElementById(nId)) {
        var div = document.getElementById(nId);
        if (IsIE()) {
            div.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="' + tab_pic[nPic] + '",sizingMethod="crop")';
        } else {
            div.style.backgroundImage = 'url(' + tab_pic[nPic] + ')';
        }
    }
   
    if (nPic < tab_pic.length - 1) nPic = nPic + 1; else nPic = 0;
    return nPic;
}

wtorek, 27 października 2009

Podmiana obrazów w znaczniku html img

fname - ID pole formularza zawierające ścieżkę i nazwę pliku
img - ID znacznika img

function CapturePath(fname,img)
{
if (document.getElementById(img))
{
oImg = document.getElementById(img);
if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent))
{
if (document.getElementById(fname).files[0]) {
oImg.src=document.getElementById(fname).files[0].getAsDataURL();
}
} else {
if (document.getElementById(fname)) {
pic = document.getElementById(fname);
oImg.src=pic.value;
}
}
}
}

środa, 12 listopada 2008

Javascript+AJAX


function ajaxFunc(step,param1)
{
var http_request;
var params;
try // Firefox, Opera 8.0+, Safari
{
http_request=new XMLHttpRequest();
}
catch (e){ // Internet Explorer
try{
http_request=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try {
http_request=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){
alert("Twoja przeglÄ_darka nie wspiera AJAX!!");
return false;
}
}
}

if (typeof http_request != "undefined") {
if (http_request.overrideMimeType) { http_request.overrideMimeType('text/xml'); }
//http_request.open("POST","inc/lektor.php",true);
(step<5) ? http_request.open("POST","inc/lektor.php",true) : http_request.open("POST","inc/katpliki.php",true); http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded;"); switch (step) { case 1 : { //utworzenie pliku tekstowego var opis=""; if (document.getElementById("opisread")) { opis=document.getElementById("opisread").value; } params="act=gen&opis="+opis; http_request.send(params); http_request.onreadystatechange=function() { if (http_request.readyState==4 && http_request.status==200) { status = document.getElementById("generator_status"); if (http_request.responseText.length>1)
{
if (parseInt(http_request.responseText[0])==0) {
status.innerHTML=http_request.responseText.substring(2); }
}
else {
if (parseInt(http_request.responseText[0])==1) { status.innerHTML="Utworzono plik tekstowy"; }
}
}
}
} break;

case 2 : { //wywolanie generatora
//filename="lektor.wav";
filename=CreateFileName("autorid","tytulid")+".mp3";
params="act=wav&file="+filename;
http_request.send(params);
status = document.getElementById("generator_status");
status.innerHTML='wywolanie generatora';
http_request.onreadystatechange=function()
{
if (http_request.readyState==4 && http_request.status==200) {
status = document.getElementById("generator_status");
if (http_request.responseText.length>1)
{
//alert(http_request.responseText);
if (parseInt(http_request.responseText[0])==0) {
status.innerHTML="WystÄ_pi__ b__Ä_d przy tworzeniu pliku mp3"; }
}
else { //alert(http_request.responseText);
if (parseInt(http_request.responseText[0])==1) {
status.innerHTML="rozpoczÄ_to tworzenie pliku";
}
}
} //alert( http_request.readyState+" "+http_request.status);
}
} break;

case 3 : {
//filename="lektor.wav";
filename=CreateFileName("autorid","tytulid")+".mp3";
params="act=mp3&file="+filename;
http_request.send(params);
http_request.onreadystatechange=function()
{
if (http_request.readyState==4 && http_request.status==200) {
status = document.getElementById("generator_status");
statusid =document.getElementsByName("statusid");
//alert(statusid[0].value);
//alert("jesten kod= "+http_request.responseText[0]);
switch (parseInt(http_request.responseText[0])) {
case 0: {
status.innerHTML="tworzenie pliku lektora ...";
statusid[0].setAttribute('value','0');
idtime=setTimeout('ajaxFunc(3)',5000);
if (document.getElementById("timerid2")) document.getElementById("timerid2").value=idtime;
} break;
case -1 : {
statusid[0].setAttribute('value','0');
idtime=setTimeout('ajaxFunc(3)',5000);
if (document.getElementById("timerid2")) document.getElementById("timerid2").value=idtime;
} break; //brak jessze pliku;
case 1: {
status.innerHTML="Utworzono plik lektora!!!"; statusid[0].setAttribute('value','1');
// progress stop //
if (document.getElementById("timerid1")) {
timeid=document.getElementById("timerid1").value;
progress(false,1,31,50,timeid);
}
if (document.getElementById("timerid2")) {
timeid=document.getElementById("timerid2").value;
clearTimeout(timeid);
}

//--stop progress --//
var filepath="..////pliki//temp//"+filename;
//alert(filepath);
var html=Mp3Player(filepath,"");
if (document.getElementById("playlektor")) document.getElementById("playlektor").innerHTML=html;
if (document.getElementById("blektorprzypisz")) document.getElementById("blektorprzypisz").style.visibility="visible";
if (document.getElementById("filelektor")) document.getElementById("filelektor").value=filename;

} break;
}

} //else alert(http_request.readyState+" "+http_request.status);
}

} break;

case 4 : {
if (document.getElementById("filelektor")) filename = document.getElementById("filelektor").value;
params="act=move&file="+filename;
http_request.send(params);
http_request.onreadystatechange=function() {
if (http_request.readyState==4 && http_request.status==200) {
//alert(http_request.responseText);
status = document.getElementById("generator_status");
if (http_request.responseText.length>0)
{
if (parseInt(http_request.responseText[0])==0) {
status.innerHTML="WystÄ_pi__ b__Ä_d przy kopiowaniu pliku mp3";
}
else {
if (parseInt(http_request.responseText[0])==1) {
status.innerHTML="Przypisano plik lektora";
}
}
// progress stop //
if (document.getElementById("timerid1")) {
timeid=document.getElementById("timerid1").value;
progress(false,1,31,50,timeid);
}
}

//Schowanie przyciskow niepotrzebnych
if (document.getElementById("blektorprzypisz")) document.getElementById("blektorprzypisz").style.visibility="hidden";
if (document.getElementById("playlektor")) document.getElementById("playlektor").innerHTML="";
}
}
} break;

case 5 : { //Odczyt listy plikow rysunkow z katalogu kategorii
params="path="+param1;
http_request.send(params);
http_request.onreadystatechange=function()
{
if (http_request.readyState==4 && http_request.status==200) {
if (http_request.responseText.length>0)
{
if (document.getElementById("kategoriepic")) {
var divpicall= document.getElementById("kategoriepic");
var lista = new Array();
var plik = new Array();
var html='';
lista = http_request.responseText.split('\n');
for (var i=0;i
";
html+="";
html+="
";
}
divpicall.innerHTML=html;
}
}
}
}
} break;
}

}
}

JavaScript+DOM

//-- Usuwa wszystkie elementy obiektu --//
function CloseAllDiv(element_id) {
if (document.getElementById(element_id)) {
var divall = document.getElementById(element_id);
while (divall) {
document.body.removeChild(divall);
divall = document.getElementById(element_id);
}
}
}

//--------------------------------------
//-- Probne funkcje do marguee bara - do realizacji w klasie
function KnightRider(id,max)
{
if (document.getElementById(id)) {
divel = document.getElementById(id);
var html=""; for (var i=1;i<=max;i++) { html+=""; } html+="
";
divel.innerHTML=html;
}
}
function progress(stan,id,max,speed,timeid,strona)
// -------- Parametry --------- //
// stan = start,stop - true/false
// id= od ktorego box - poczatkowy nr 1
// ilosc max box
// speed - predko__Ä_ 50/100 mls
// timeid - identyfikator - ostatniego id przy setTimeout
// strona (true = w prawo/left - lewo) - w ktora strone zaczynamy
{
var col='';
if (stan==true)
{
if (strona==true) {

for (var i=1;i1;i--) {
if (document.getElementById("prog"+i)) document.getElementById("prog"+i).style.backgroundColor="white";
}
if (document.getElementById("prog"+id)) document.getElementById("prog"+id).style.backgroundColor="red";
for (var i=id+1;i<=max;i++) { if (document.getElementById("prog"+i)) { switch (i-id) { case 5: col="#FFEFEF";break; case 4: col="#FFBFBF";break; case 3: col="#FF8F8F";break; case 2: col="#FF5F5F";break; case 1: col="#FF2F2F";break; default: col="white"; } document.getElementById("prog"+i).style.backgroundColor=col; } } id1=id; id1--; if (id1==(0)) { id1=1; strona=true; } } timeid =setTimeout('progress(true,'+id1+','+max+','+speed+',0,'+strona+')',speed); if (document.getElementById("timerid1")) document.getElementById("timerid1").value=timeid; } else { clearTimeout(timeid); for (var i=1;i<=max;i++) { if (document.getElementById("prog"+i)) document.getElementById("prog"+i).style.backgroundColor="white"; } } return timeid; } //- wywolanie ---KnightRider("generator",31);