Jump to content


Photo

Need help with php scripts


  • Please log in to reply
No replies to this topic

#1 rush

rush
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 11 May 2006 - 11:25 AM

Hi,

I have created an extension with firefox which will work as a quick image upload tool for my image server.

Now the issue is my server needs to have some supporting php scripts for this to work.

Can someone help me on this..??
thanks for reading

The actual javascript is this:

window.addEventListener("load", initOverlay, false);
var didit = 0;

function initOverlay() {
  var menu = document.getElementById("yourFiles");
  menu.addEventListener("popupshowing", contextPopupshowing, false);
}


function contextPopupshowing() {
if (didit==1) { return false; }
var xmlhttp;
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", "http://***.***.com/emyfiles.php",true);
xmlhttp.onreadystatechange=function() {
 if (xmlhttp.readyState==4) {
        doList(xmlhttp.responseText);
 }
}
xmlhttp.send(null);
}

function doList(data) {
var files=data.split("\n");
var fields;
var uid;
var fname;
var output="";
var incat = document.getElementById("yourFiles");
for (var i=0; i < files.length -2; i++ ) {
        fields=files[i].split("\t");
        uid = fields[0];
        fname = fields[1];
        output += i + ": <a href=\"http://***.***.com/files/" + uid + "/" + fname + "\">" + fname + "</a><br />\n";
        var ja = document.createElement("menuitem");
        ja.setAttribute("label",fname);
        ja.setAttribute("oncommand","gotourl(\"http://***.***.com/detail.php?id=" + uid + "\");");
    incat.childNodes[0].appendChild(ja);
}
didit=1;
}


function gotourl(url) {
const newTab = getBrowser().addTab(url);

getBrowser().selectedTab = newTab;
generatedPage = window;
}


// This is my javascript, which will pop up my message
// in an alert box.

var hush = {
loadSite: function(mode) {
gotourl('http://***.***.com');
return false;
},

loadLink: function(mode) {
var url = 'test';
if (mode == 1) {
    url = gContextMenu.linkURL();
}
if (mode == 2) {
    url = gContextMenu.imageURL;
}
if (url == '' || url == 'undefined' || url=='Undefined') {
    if (mode == 1) {
        window.alert('Please select a link');
        return false;
    }
    if (mode == 2) {
        window.alert('Please select an image');
        return false;
    }
}
gotourl('http://***.***.com/process.php?remotefile=' + url);
return false;
}

Someone please help, thanks





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users