Scripts | Codes

All languages in three languages :-)
Showing posts with label browser. Show all posts

Une requête AJAX qui marche sur tout les navigateurs avec toutes les versions...

An AJAX request that works on all browsers with all versions

تطبيق أجاكس التي تعمل على جميع المتصفحات مع جميع الإصدارات..


Open in a new window
//###################################################
// find more codes on scripts-n-codes.blogspot.com
//###################################################
//
//  this files -> ajax.js (to include on pages that uses ajax requests)
//
function get_url(url) {
 var request = false;  
 if(window.XMLHttpRequest) {  
  request = new XMLHttpRequest();  
  if(request.overrideMimeType) {  
   request.overrideMimeType('text/xml');  
  }  
 } else if(window.ActiveXObject) {  
  var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP.6.0', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'];  
  for(var i=0; i<versions.length; i++) {  
   try {  
    request = new ActiveXObject(versions[i]);  
   } catch(e) {}  
  }  
 }  
 xmlHttpReq = request;  
 xmlHttpReq.open("GET",url, false);
 xmlHttpReq.send(null);
 return xmlHttpReq.responseText; 
}





Un exemple de comment utiliser AJAX pour rafraichir une page sans l'actualiser...
Sans commentaires

An example of how to use AJAX to refresh a page without updating it ...
No comments

مثال عن كيفية إستعمال أجاكس لتحديث جزء من صفحة دون تحديثها كليا 

بدون تعليق 

Open in a new window
//##################################################
// find more codes on codes-n-scripts.blogspot.com
//##################################################
//
// this is ajax.js file
//

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(action) {
    http.open('get', 'ajax.php?action='+action);
    http.onreadystatechange = handleResponse;
    http.send(null);
}

function handleResponse() {
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            update = response.split('|');
            document.getElementById(update[0]).innerHTML = update[1];
        }
    }
}


<?
//##################################################
// find more codes on codes-n-scripts.blogspot.com
//##################################################
//
// this is ajax.php file
//

  switch($_REQUEST['action']) {
    case 'A1':
      echo "A1|Je suis dans la case bleue";
      break;
    case 'B1':
      echo "B1|je suis dans la case verte";
      break;
  }

?>

<html><body>
<script src="ajax.js"></script>
<!-- find more codes on codes-n-scripts.blogspot.com -->
<!-- this is index.html -->
<TABLE BORDER="0">
<TR>
<TD id="A1" HEIGHT="200" WIDTH="197" BGCOLOR="blue" ALIGN="center">
</TD>
</TR>
<TR>
<TD id="B1" BGCOLOR="green" ALIGN="center">
</TD>
<TD HEIGHT="350" WIDTH="750" BGCOLOR="red" id="B2" ALIGN="center">
<a href="javascript:sndReq('A1')">Afficher un text dans la case bleue</a><BR>
<a href="javascript:sndReq('B1')">Afficher un text dans la case verte</a>
</TD>
</TR>
</TABLE>
</body></html>

Permet de récupérer les cookies d'un site dans Firefox...
Utilisation:
- D'abord l'enregistrer sous un fichier appelé par exemple cooky.py
- Modifier dans les deux lignes suivantes:
cookiedb = '{$HOME}/.mozilla/firefox/vkuuxfit.default/cookies.sqlite'
targetfile = '{$HOME}/Bureau/cookies.txt'
- {$HOME} par le chemin vers votre dossier personnel : par exemple pour moi /home/ubu
- le nom un peu bizzare "vkuuxfit.default" par celui que vous trouverez dans le repertoire de ff, c-à-d ici : {$HOME}/.mozilla/firefox , normalement il ne devrait y'en avoir qu'un seul, celui finissant par "default" sinon si vous avez crée d'autres profiles, mettre le nom du répertoire du profile par lequel vous vous être connécté au site que vous voulez télécharger (par login et pwd) ... vous devriez facilement reconnaitre le dossier, car son nom finit par ".nom_du_profile".
Si vous voulez changer le nom du repertoire où sera stocké le fichier cookies.txt libre à vous.
- Exécuter le script avec le nom du site en premier argument, par exemple je veux récupérer les cookies du site "siteduzero.com" je tape: python cooke.py siteduzero.com
et j'aurais un fichier cookies.txt comme ceci :
-----------------------------------------------------
www.siteduzero.com TRUE / FALSE 1279648744 pseudo ubu
www.siteduzero.com TRUE / FALSE 1279648744 pass 8da0432739423d4ab36c3108a3abahc0187e7c27
www.siteduzero.com TRUE / FALSE 1279648744 hash 02af28288e9c0747be5402f48fg17788863bf423
www.siteduzero.com TRUE / FALSE 1279648744 mid2 11569111567
-----------------------------------------------------
Ce qui veut dire que l'on a les 4 variables avec les valeurs:
pseudo=ubu
pass=8da0432739423d4ab36c3108a3abahc0187e7c27
hash=02af28288e9c0747be5402f48fg17788863bf423
mid2=115691115677

To retrieve cookies of a site in Firefox ...
Usage: 
- First, save it under a file called eg. cooky.py 
- Modify the following two lines: 
cookiedb = '$(HOME)/.mozilla/firefox/vkuuxfit.default/cookies.sqlite' 
targetfile = '$(HOME)/Desktop/cookies.txt' 
- $(HOME) with the path to your home directory: for example for me /home/ubu 
- The name a bit weired "vkuuxfit.default" by the one you found in the repertoire of ff, ie here: $ (HOME)/.mozilla/firefox, you should find only one, the one ending with the string "default", if not you probalby created some other profiles, put the name of the directory of the profile which you'll use to be connected to the site. You should easily recognize the file because its name ends with ".name_of_profile. 
If you want to rename the directory where the file will be stored cookies.txt free to you. 
- Now to run the script: 
- Run the script with the name of the site as a first argument, for example I want to retrieve cookies from the site "siteduzero.com" I type: python cooky.py siteduzero.com 
and I would have a cookies.txt file like this: 
------------------------------------------------------ 
www.siteduzero.com TRUE / FALSE 1279648744 nickname ubu 
www.siteduzero.com TRUE / FALSE 1279648744 pass 8da0432739423d4ab36c3108a3abahc0187e7c27 
www.siteduzero.com TRUE / FALSE 1279648744 hash 
------------------------------------------------------
This means that we have the 4 variables with values:
nickname = ubu
pass = 8da0432739423d4ab36c3108a3abahc0187e7c27
hash = 02af28288e9c0747be5402f48fg17788863bf423
Mid2 = 115,691,115,677

لإستخراج ملفات تعريف الارتباط Cookies لموقع ما في فايرفوكس...

أولا احفظه تحت ملف مثلا cooky.py
ثانيا تعديل السطرين التاليين :
cookiedb = '{$HOME}/.mozilla/firefox/vkuuxfit.default/cookies.sqlite'

targetfile = '{$HOME}/Bureau/cookies.txt'
حيث تعوض $HOME  بمسار ملفك الشخصي و vkuuxfit بإسم ملف Firefox 
ثالثا تشغيل البرنامج النصي python cooky.py mysite.com
نتحصل على ملف cookies.txt

Open in a new window
#!/usr/bin/python
import sqlite3 as db
import sys
cookiedb = '{$HOME}/.mozilla/firefox/vkuuxfit.default/cookies.sqlite'
targetfile = '{$HOME}/Bureau/cookies.txt'
what = sys.argv[1]
connection = db.connect(cookiedb)
cursor = connection.cursor()
contents = "host, path, isSecure, expiry, name, value"
cursor.execute("SELECT " +contents+ " FROM moz_cookies WHERE host LIKE '%" 
+what+ "%'")
file = open(targetfile, 'w')
index = 0
for row in cursor.fetchall():
file.write("%s\tTRUE\t%s\t%s\t%d\t%s\t%s\n" % (row[0], row[1],
str(bool(row[2])).upper(), row[3], str(row[4]), str(row[5])))
index += 1
file.close()
connection.close()
print "Keywords: %s" % what
print "Exported: %d" % index

Subscribe to: Posts (Atom)
attendez....