[xiph-commits] r15082 - in trunk/oggPusher: . Server firefox-extension/chrome/content

nithin at svn.xiph.org nithin at svn.xiph.org
Sat Jun 28 17:25:15 PDT 2008


Author: nithin
Date: 2008-06-28 17:25:13 -0700 (Sat, 28 Jun 2008)
New Revision: 15082

Added:
   trunk/oggPusher/Server/
   trunk/oggPusher/Server/README
   trunk/oggPusher/Server/upload.php
Modified:
   trunk/oggPusher/firefox-extension/chrome/content/op_Window.js
   trunk/oggPusher/firefox-extension/chrome/content/op_Window.xul
   trunk/oggPusher/oggPusher.xpi
Log:
Adding Upload. But its not functioanal

Added: trunk/oggPusher/Server/README
===================================================================
--- trunk/oggPusher/Server/README	                        (rev 0)
+++ trunk/oggPusher/Server/README	2008-06-29 00:25:13 UTC (rev 15082)
@@ -0,0 +1,2 @@
+Presently the URL for the upload is hardcoded as 
+http://localhost/upload.php

Added: trunk/oggPusher/Server/upload.php
===================================================================
--- trunk/oggPusher/Server/upload.php	                        (rev 0)
+++ trunk/oggPusher/Server/upload.php	2008-06-29 00:25:13 UTC (rev 15082)
@@ -0,0 +1,21 @@
+<?php
+// In PHP versions earlier than 4.1.0, $HTTP_POST_FILES should be used instead
+// of $_FILES.
+
+$uploaddir = '/var/www/uploads/';
+$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
+
+//echo '<pre>';
+if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
+    echo "File is valid, and was successfully uploaded.\n";
+} else {
+    echo "Possible file upload attack!\n";
+}
+
+//echo 'Here is some more debugging info:';
+//print_r($_FILES);
+
+//print "</pre>";
+
+?>
+

Modified: trunk/oggPusher/firefox-extension/chrome/content/op_Window.js
===================================================================
--- trunk/oggPusher/firefox-extension/chrome/content/op_Window.js	2008-06-28 20:18:42 UTC (rev 15081)
+++ trunk/oggPusher/firefox-extension/chrome/content/op_Window.js	2008-06-29 00:25:13 UTC (rev 15082)
@@ -1,11 +1,17 @@
 var opwindowCommon={
 	openFileWindowDialog:function()
         {
-                const nsIFilePicker = Components.interfaces.nsIFilePicker;
-                var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
-                fp.init(window, "Choose a File", nsIFilePicker.modeOpen);
-                fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
-
+		alert("Inside openFileWindowDialog");
+		try{
+                	const nsIFilePicker = Components.interfaces.nsIFilePicker;
+	                var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
+        	        fp.init(window, "Choose a File", nsIFilePicker.modeOpen);
+                	fp.appendFilters(nsIFilePicker.filterAll | nsIFilePicker.filterText);
+		}	
+		catch(err){
+			alert(err);
+			return;
+		}
                 var rv = fp.show();
                 if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
                 	var file = fp.file;
@@ -15,7 +21,7 @@
          },
 	 myComponentTestGo:function()
 	 {
-		alert("Start of MyComponentTestGo()");
+		//alert("Start of MyComponentTestGo()");
         	try {
                		netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
                 	const cid = "@mydomain.com/XPCOMSample/MyComponent;1";
@@ -29,7 +35,31 @@
         	}
         	var res = obj.Add(3, 4);
         	alert('Performing 3+4. Returned ' + res + '.');
+	},
+	uploadFile:function()
+	{
+		try{
+			var filePath = document.getElementById("file-path").value;
+			var file = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
+			file.initWithPath(filePath);
+			var fstream = Components.classes['@mozilla.org/network/file-input-stream;1'].createInstance(Components.interfaces.nsIFileInputStream);
+			fstream.init(file, 1, 1, Components.interfaces.nsIFileInputStream.CLOSE_ON_EOF);
+			var bstream = Components.classes['@mozilla.org/network/buffered-input-stream;1'].createInstance(Components.interfaces.nsIBufferedInputStream);
+			bstream.init(fstream, 4096);
+			xhr = new XMLHttpRequest();
+		}
+		catch(err){
+			alert(err);
+			return;
+		}
+	        xhr.onreadystatechange = function() { if(this.readyState == 4) {alert(this.responseText)}}
+		xhr.open("POST", "http://localhost/upload.php", true);
+		xhr.setRequestHeader('Content-Type', 'application/octet-stream');
+		xhr.send(bstream);
+		
+
 	}
+	
 
 }
 

Modified: trunk/oggPusher/firefox-extension/chrome/content/op_Window.xul
===================================================================
--- trunk/oggPusher/firefox-extension/chrome/content/op_Window.xul	2008-06-28 20:18:42 UTC (rev 15081)
+++ trunk/oggPusher/firefox-extension/chrome/content/op_Window.xul	2008-06-29 00:25:13 UTC (rev 15082)
@@ -12,9 +12,9 @@
      <vbox>	
      	<label value="Locate Files on your computer:" control="browse-button"/>
 	<hbox>
-		<textbox id="file-path" control="browse-button" disabled="true" style="width:700px"/>
-      		<button id="browse-button" label="Browse..." oncommand=" opwindowCommon.openFileWindowDialog();"/>
-
+		<textbox id="file-path" control="browse-button" disabled="true" style="width:400px"/>
+      		<button id="browse-button" label="Browse..." oncommand="opwindowCommon.openFileWindowDialog();"/>
+		<button id="upload-button" label="Upload" oncommand="opwindowCommon.uploadFile();"/>
 	</hbox>
      </vbox>
 

Modified: trunk/oggPusher/oggPusher.xpi
===================================================================
(Binary files differ)



More information about the commits mailing list