Jump to content

Recommended Posts

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:

[code]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;
}[/code]

Someone please help, thanks
Link to comment
https://forums.phpfreaks.com/topic/9540-need-help-with-php-scripts/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.