UniUploader:Advanced
(9 intermediate revisions by one user not shown) | |||
Line 3: | Line 3: | ||
{{MainMenu|UniUploader}} | {{MainMenu|UniUploader}} | ||
− | == | + | === Common Practices === |
− | + | UU is designed to provide basic functionality with minimal settings. One of the best ways to set this up as an administrator is to "pre-configure" UU and then distribute it to Guild Members. This way your users don't have to worry about any of the settings in UU. They can just run the exe and they are ready for action. [[UniAdmin]] is also used for [[UniUploader]] administration and offers the ability to change settings without distributing a new installer. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | There is a drawback to this that is difficult to avoid. The problem is, however, rare. When changing the Updater Interface URL, the only way to update UU, is to redistribute UU. This is sometimes annoying for you and/or the Guild members. | ||
+ | The NSIS script allows you to build your own installer. To include guild settings in the installer, construct a settings.ini file then un-comment a line in the script (will see how to do this in the script itself, quite trivial). See [[UniUploader:Distribution|UniUploader Distribution]] for more information. | ||
− | + | They are some good ways to ensure your users have everything running properly and the way you want it to. You could turn on "Auto-Launch WoW" and/or "Start with Windows". Then instruct your users to just run UU and it will launch WoW, so they can essentially replace any links to the WoW executable, and just use UU to start WoW. | |
− | + | ||
− | + | ||
− | + | {{Warning|Warning|Settings such as "Start with Windows" and "Auto-launch WoW" must be dealt with carefully since these settings could anger your users if they don't desire this level of automation.}} | |
− | + | ||
− | + | ||
You can customize UU with your own images.<br> | You can customize UU with your own images.<br> | ||
− | There are currently 2 images | + | There are currently 2 images in UU, which are logo1.gif and logo2.gif. logo1.gif is displayed in the Settings tab on the right, and logo2.gif is on the about tab. You don't need to have the images there if you want the distrib to be smaller.<br> |
If you do wish to equip UU with either or both of the images, here are the requirements: | If you do wish to equip UU with either or both of the images, here are the requirements: | ||
− | # | + | # The images must be named correctly |
− | # | + | # The images must be in the same directory as UU |
− | # | + | # The images must be a certain format (GIF, JPG, PNG) |
− | # | + | # The images can have wierd dimensions, but it is not recommended |
+ | #* logo1.gif - 216x144 | ||
+ | #* logo2.gif - 320x176 | ||
If you have support for GZip compression in your interface file, by all means turn that on.<br> | If you have support for GZip compression in your interface file, by all means turn that on.<br> | ||
− | Using compression is good, it will trim a file such as 5 megabytes down to ~20K, | + | Using compression is good, it will trim a file such as 5 megabytes down to ~20K, greatly increasing bandwidth efficiency. |
If you have support for addon updates and/or Website==>WoW communication support in your website, set those up. See [[UniUploader:Advanced#Addon_Updater|Section 4: Addon Updater]] and [[UniUploader:Advanced#Website_.3D.3D.3E_WoW|Section 5: Website ==> WoW]] for details about these systems. | If you have support for addon updates and/or Website==>WoW communication support in your website, set those up. See [[UniUploader:Advanced#Addon_Updater|Section 4: Addon Updater]] and [[UniUploader:Advanced#Website_.3D.3D.3E_WoW|Section 5: Website ==> WoW]] for details about these systems. | ||
− | Now that you have all that out of the way, all you have to do is set up the Primary Interface URL, which is your website file that | + | Now that you have all that out of the way, all you have to do is set up the Primary Interface URL, which is your website file that receives the uploads. The setting is in the Settings Tab on the top.<br> |
− | + | Re zip the ini file, the images (if you opted to include them), and the executable. Upload your package and distribute it to your users. | |
=== Basic Setup === | === Basic Setup === | ||
− | The only setting that must be set for UU to perform its basic upload is the Primary URL setting which can be found on the Settings tab. This is the interface file on your website that | + | The only setting that must be set for UU to perform its basic upload is the Primary URL setting which can be found on the Settings tab. This is the interface file on your website that receives the SV file uploads. Once this is set, UU will automatically upload on file changes (unless you turned that off). You can set "Additional URL's" in the Options tab.<br> |
− | + | You can set up to 4 additional URL's. the second field in these settings. | |
− | Note that any data | + | Note that any data received by the additional url's will not show in the server response window, and if you are using compression, SV will be compressed before uploading to any of the additional url's. |
− | If | + | If you have authorization using traditional form fields both hidden and visible, "additional variables" fields. Replace "arg1" with "username" (this is the name of the variable), and "value1" with the actual username. Use the same method for the password. You can use the "additional variables" for other things such as hidden form fields. In fact hidden and Visible form fields are all additional variables. |
+ | There may not be permutations between fields and sites. This limitation is a long root in the program's history, and needs to be pulled. | ||
=== Compression === | === Compression === | ||
− | To use compression, your interface file(s) must support it. | + | To use gzip compression, your interface file(s) must support it. Here is an example in PHP: |
<php>function GetUploadedLocalFilename() | <php>function GetUploadedLocalFilename() | ||
{ | { | ||
Line 77: | Line 72: | ||
=== Addon Updater === | === Addon Updater === | ||
− | + | The updater interface must be set up in a way that it can respond to all of UU's operations. Here is how it works: UU sends a request to the interface, OPERATION = GETADDONLIST , the interface file must respond with ONLY the xml file which is formatted as follows (example): | |
<xml><addons> | <xml><addons> | ||
<addon name="CharacterProfiler" version="0.97" toc="11000" required="1" > | <addon name="CharacterProfiler" version="0.97" toc="11000" required="1" > | ||
Line 103: | Line 98: | ||
This system provides a way for data from a website to be inserted into the SV file for use in WoW Mod's, essentially making it possible to run Full-Duplex (WoW (==) Website) WoW Addons. | This system provides a way for data from a website to be inserted into the SV file for use in WoW Mod's, essentially making it possible to run Full-Duplex (WoW (==) Website) WoW Addons. | ||
− | You can find the settings for this | + | You can find the settings for this system in the Advanced tab in the middle. UU first reads the data from the URL, then appends the data to the bottom of the specified SV file exactly as recieved from the URL. |
− | After the data from the website has been appended into the SV file, WoW Addon's can use the data. When logging out of WoW, if 1 or more addons have RegisterForSave set for the data, then it will remain in the SV file. There should never be more than 1 copy of the same variable in the SV file if the upload button | + | After the data from the website has been appended into the SV file, WoW Addon's can use the data. When logging out of WoW, if 1 or more addons have RegisterForSave set for the data, then it will remain in the SV file. There should never be more than 1 copy of the same variable in the SV file if the upload button isn't pressed manually. If there are more than 1 of the same variable/data in the SV file, the addons will use the last (latest) copy of the variable/data. UniUploader will retrieve and append the data every time the upload button is pressed and (if option is set) when changes in the SV file are detected. |
− | === | + | === Upload Data Info === |
− | When UU uploads files, the size of the uncompressed files are sent as integers, (# of bytes), only if gzip is turned on. For every checked SV, there will be a POST variable sent like this: | + | When UU uploads files, a few extra post variables are passed: |
− | usize_ + name of checked SV = # of bytes | + | * the size of the uncompressed files are sent as integers, (# of bytes), only if gzip is turned on. For every checked SV, there will be a POST variable sent like this: |
− | so if it were uploading a SV called myAddon.lua: | + | ** usize_ + name of checked SV = # of bytes |
− | usize_myAddon=123456 | + | *** so if it were uploading a SV called myAddon.lua: usize_myAddon=123456 |
+ | * The local time of the computer running UU in both regular and UTC. | ||
+ | * The UU User Agent is passed via the HTTP Header, which also contains the UU Version. | ||
+ | ==== Variable Snapshot ==== | ||
+ | _REQUEST["usize_CharacterProfiler"] 712529 | ||
+ | _REQUEST["clientTime"] 2007-08-09T19:06:09Z | ||
+ | _REQUEST["clientTimeUTC"] 2007-08-09T23:06:09Z | ||
+ | _POST["usize_CharacterProfiler"] 712529 | ||
+ | _POST["clientTime"] 2007-08-09T19:06:09Z | ||
+ | _POST["clientTimeUTC"] 2007-08-09T23:06:09Z | ||
+ | _SERVER["HTTP_USER_AGENT"] UniUploader 2.0 (UU 2.6.7; English) | ||
+ | _SERVER["CONTENT_TYPE"] multipart/form-data; boundary=698585d85ac04b7da6e40e52dc73542b | ||
+ | _FILES["CharacterProfiler"] Array | ||
+ | ( | ||
+ | [name] => CharacterProfiler.lua | ||
+ | [type] => application/octet-stream | ||
+ | [tmp_name] => C:\DOCUME~1\Matt\LOCALS~1\Temp\php\upload\php56.tmp | ||
+ | [error] => 0 | ||
+ | [size] => 712529 | ||
+ | ) | ||
+ | ==== Raw Data ==== | ||
+ | This is a reassembled UniUploader TCP data stream with the binary data cut out: | ||
+ | POST /info.php HTTP/1.1 | ||
+ | User-Agent: UniUploader 2.0 (UU 2.6.7; English) | ||
+ | Content-Type: multipart/form-data; boundary=e62f89ca2c714e0dac26d9c465641710 | ||
+ | Accept: application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 | ||
+ | Content-Length: 110174 | ||
+ | Connection: Keep-Alive | ||
+ | Host: foolyfrag.com | ||
+ | |||
+ | |||
+ | --e62f89ca2c714e0dac26d9c465641710 | ||
+ | Content-Disposition: form-data; name="usize_FuBar" | ||
+ | |||
+ | 1101 | ||
+ | --e62f89ca2c714e0dac26d9c465641710 | ||
+ | Content-Disposition: form-data; name="FuBar"; filename="FuBar.lua.gz" | ||
+ | Content-Type: application/octet-stream | ||
+ | |||
+ | *BINARY DATA REMOVED FOR WIKI* | ||
+ | --e62f89ca2c714e0dac26d9c465641710 | ||
+ | Content-Disposition: form-data; name="usize_PvPLog" | ||
+ | |||
+ | 38319 | ||
+ | --e62f89ca2c714e0dac26d9c465641710 | ||
+ | Content-Disposition: form-data; name="PvPLog"; filename="PvPLog.lua.gz" | ||
+ | Content-Type: application/octet-stream | ||
+ | |||
+ | *BINARY DATA REMOVED FOR WIKI* | ||
+ | --e62f89ca2c714e0dac26d9c465641710 | ||
+ | Content-Disposition: form-data; name="usize_CharacterProfiler" | ||
+ | |||
+ | 712529 | ||
+ | --e62f89ca2c714e0dac26d9c465641710 | ||
+ | Content-Disposition: form-data; name="CharacterProfiler"; filename="CharacterProfiler.lua.gz" | ||
+ | Content-Type: application/octet-stream | ||
+ | |||
+ | *BINARY DATA REMOVED FOR WIKI* | ||
+ | --e62f89ca2c714e0dac26d9c465641710 | ||
+ | Content-Disposition: form-data; name="clientTime" | ||
+ | |||
+ | 2007-08-09T19:28:20Z | ||
+ | --e62f89ca2c714e0dac26d9c465641710 | ||
+ | Content-Disposition: form-data; name="clientTimeUTC" | ||
+ | |||
+ | 2007-08-09T23:28:20Z | ||
+ | --e62f89ca2c714e0dac26d9c465641710-- | ||
+ | |||
+ | === Screenshot Protocol === | ||
+ | |||
+ | |||
+ | # UU posts OPERATION=CHECKSHOTS and data={a '\n' separated list of md5 hashes of the screenshots } | ||
+ | # Interface responds with which a '\n' separated list of md5 hashes for screenshots not uploaded yet | ||
+ | # UU posts OPERATION=UPSHOTS and the screenshot files (.jpg) to the same url. | ||
+ | |||
+ | All of this happens with the Primary Interface URL (the one that shows up on first tab in UU) | ||
+ | The contents of the PHP variable $_FILES after the post is complete in step 3 could be: | ||
+ | |||
+ | Array | ||
+ | ( | ||
+ | [ef1c521103e556db3fd2bca88c83bdea] => Array | ||
+ | ( | ||
+ | [name] => WoWScrnShot_080908_155425.jpg | ||
+ | [type] => application/octet-stream | ||
+ | [tmp_name] => /data/tmp/phpvhE5Wb | ||
+ | [error] => 0 | ||
+ | [size] => 276956 | ||
+ | ) | ||
+ | ) | ||
+ | |||
+ | Example Screenshot Interface Script: | ||
+ | <php><?php | ||
+ | // CREATE TABLE `screenshots` ( | ||
+ | // `id` INT( 11 ) NOT NULL AUTO_INCREMENT , | ||
+ | // `fingerprint` VARCHAR( 32 ) NOT NULL , | ||
+ | // `data` LONGBLOB NOT NULL , | ||
+ | // PRIMARY KEY ( `id` ) | ||
+ | // ) ENGINE = MYISAM | ||
+ | $op=get_var("OPERATION"); | ||
+ | $db=mysql_connect("localhost", "??????", "??????"); | ||
+ | mysql_select_db("test",$db); | ||
+ | switch($op){ | ||
+ | |||
+ | case 'CHECKSHOTS': | ||
+ | check_shots(); | ||
+ | break; | ||
+ | |||
+ | case 'UPSHOTS': | ||
+ | up_shots(); | ||
+ | break; | ||
+ | |||
+ | default: | ||
+ | break; | ||
+ | } | ||
+ | function up_shots(){ | ||
+ | global $db; | ||
+ | //print_r($_FILES); | ||
+ | foreach($_FILES as $file){ | ||
+ | //do whatever with them | ||
+ | //always insert into db so user does not have to upload same screenshots again indefinitley | ||
+ | } | ||
+ | } | ||
+ | function check_shots(){ | ||
+ | $data = get_var("data"); | ||
+ | $rows = explode("\n",$data); | ||
+ | $donthaveyet = array(); | ||
+ | foreach($rows as $row){ | ||
+ | if (!doihave($row)){ | ||
+ | $donthaveyet[] = $row; | ||
+ | } | ||
+ | } | ||
+ | $out = implode("\n",$donthaveyet); | ||
+ | echo $out; | ||
+ | } | ||
+ | function doihave($fingerprint){ | ||
+ | global $db; | ||
+ | $result = mysql_query("select * from screenshots where fingerprint='".$fingerprint."'",$db); | ||
+ | return (mysql_num_rows($result)< 1) ? false : true; | ||
+ | } | ||
+ | function get_var($var){ | ||
+ | $out = ''; | ||
+ | if (isset($_POST[$var])) | ||
+ | $out = $_POST[$var]; | ||
+ | |||
+ | if (isset($_REQUEST[$var])) | ||
+ | $out = $_REQUEST[$var]; | ||
+ | |||
+ | return $out; | ||
+ | } | ||
+ | ?></php> |
Latest revision as of 15:56, 7 July 2009
Important note: When you edit this page, you agree to release your contribution into the public domain. |
Contents |
Common Practices
UU is designed to provide basic functionality with minimal settings. One of the best ways to set this up as an administrator is to "pre-configure" UU and then distribute it to Guild Members. This way your users don't have to worry about any of the settings in UU. They can just run the exe and they are ready for action. UniAdmin is also used for UniUploader administration and offers the ability to change settings without distributing a new installer.
There is a drawback to this that is difficult to avoid. The problem is, however, rare. When changing the Updater Interface URL, the only way to update UU, is to redistribute UU. This is sometimes annoying for you and/or the Guild members.
The NSIS script allows you to build your own installer. To include guild settings in the installer, construct a settings.ini file then un-comment a line in the script (will see how to do this in the script itself, quite trivial). See UniUploader Distribution for more information.
They are some good ways to ensure your users have everything running properly and the way you want it to. You could turn on "Auto-Launch WoW" and/or "Start with Windows". Then instruct your users to just run UU and it will launch WoW, so they can essentially replace any links to the WoW executable, and just use UU to start WoW.
You can customize UU with your own images.
There are currently 2 images in UU, which are logo1.gif and logo2.gif. logo1.gif is displayed in the Settings tab on the right, and logo2.gif is on the about tab. You don't need to have the images there if you want the distrib to be smaller.
If you do wish to equip UU with either or both of the images, here are the requirements:
- The images must be named correctly
- The images must be in the same directory as UU
- The images must be a certain format (GIF, JPG, PNG)
- The images can have wierd dimensions, but it is not recommended
- logo1.gif - 216x144
- logo2.gif - 320x176
If you have support for GZip compression in your interface file, by all means turn that on.
Using compression is good, it will trim a file such as 5 megabytes down to ~20K, greatly increasing bandwidth efficiency.
If you have support for addon updates and/or Website==>WoW communication support in your website, set those up. See Section 4: Addon Updater and Section 5: Website ==> WoW for details about these systems.
Now that you have all that out of the way, all you have to do is set up the Primary Interface URL, which is your website file that receives the uploads. The setting is in the Settings Tab on the top.
Re zip the ini file, the images (if you opted to include them), and the executable. Upload your package and distribute it to your users.
Basic Setup
The only setting that must be set for UU to perform its basic upload is the Primary URL setting which can be found on the Settings tab. This is the interface file on your website that receives the SV file uploads. Once this is set, UU will automatically upload on file changes (unless you turned that off). You can set "Additional URL's" in the Options tab.
You can set up to 4 additional URL's. the second field in these settings.
Note that any data received by the additional url's will not show in the server response window, and if you are using compression, SV will be compressed before uploading to any of the additional url's.
If you have authorization using traditional form fields both hidden and visible, "additional variables" fields. Replace "arg1" with "username" (this is the name of the variable), and "value1" with the actual username. Use the same method for the password. You can use the "additional variables" for other things such as hidden form fields. In fact hidden and Visible form fields are all additional variables.
There may not be permutations between fields and sites. This limitation is a long root in the program's history, and needs to be pulled.
Compression
To use gzip compression, your interface file(s) must support it. Here is an example in PHP:
function GetUploadedLocalFilename() { global $filefield, $_FILES; //filefield is the name of the file array uploaded if (isset($_FILES[$filefield])) { if (substr_count($_FILES[$filefield]['name'],".gz") > 0) { $filename = $_FILES[$filefield]['tmp_name']; $tempHandle = gzopen($filename, "r"); //uncompress $contents = fread($tempHandle,5000000); //read up to 5 megs (no way to see total uncompressed length :( ) fclose($tempHandle); $tmpfname = tempnam("","luatemp"); //create temp file for uncompressed data $handle = fopen($tmpfname, "w"); fwrite($handle, $contents); //write the uncompressed temp file fclose($handle); return $tmpfname; //return the filename (with full path) } else { return $_FILES[$filefield]['tmp_name']; } } else { return ""; } }
Addon Updater
The updater interface must be set up in a way that it can respond to all of UU's operations. Here is how it works: UU sends a request to the interface, OPERATION = GETADDONLIST , the interface file must respond with ONLY the xml file which is formatted as follows (example):
<addons> <addon name="CharacterProfiler" version="0.97" toc="11000" required="1" > <file name="CharacterProfiler.lua" md5sum="d64d775f5015b16390034ef72688b632" /> <file name="CharacterProfiler.toc" md5sum="255417db5329ad7a88e8fd1cbd997149" /> <file name="CharacterProfiler.xml" md5sum="287a42a55384dad5f10cbf8f92b36bd4" /> </addon> <addon name="guildextract" version="0.0.0" toc="11000" required="0"> <file name="Guildextract.xml" md5sum="0ceddad51783ed35bf4d53f353729f3b" /> <file name="guildextract.lua" md5sum="95b1a7fcd0926c3c439cdb0215dea45b" /> <file name="guildextract.toc" md5sum="b96c0c500e1cce8f898dd283bdbe1588" /> </addon> </addons>
UU then checks to see if the user has the addons installed, and if so, checks the md5sum of the files on the user's hard drive matches that from the xml data. If any of the files from a particular addon are outdated (md5's dont match), that addon's download URL is then requested like this:
- UU sends a request to the interface with 2 variables set, variable 1: OPERATION = GETADDON , variable 2: ADDON = "AddonName" where AddonName is the name of the folder that should be in the InterfaceAddOns folder, and is the same name used in the xml file.
- The interface file returns something like eg. http://somewhere.com/updater/AbcWoWMod.zip
The zip file must have the following directory structure: Interface/AddOns/AbcWoWMod/ with the parent folders included with the zip. UU then downloads the URL location (the zip file) , unzips it, and moves it to the correct wow addons directory.
The interface file must keep a current database with each md5sum of the addon's files, the names of the addons, and the location of the zip download. If the database and the zip files don't match you will have many problems, there is a possibility of UU trying to update the affected addon's every time, or returning an error.
The interface file can be integrated with the main interface by using something like a PHP case() function for the _REQUEST['OPERATION']. The Section 5: Website ==> WoW system also sends a similar request to the interface.
Website ==> WoW
This system provides a way for data from a website to be inserted into the SV file for use in WoW Mod's, essentially making it possible to run Full-Duplex (WoW (==) Website) WoW Addons.
You can find the settings for this system in the Advanced tab in the middle. UU first reads the data from the URL, then appends the data to the bottom of the specified SV file exactly as recieved from the URL. After the data from the website has been appended into the SV file, WoW Addon's can use the data. When logging out of WoW, if 1 or more addons have RegisterForSave set for the data, then it will remain in the SV file. There should never be more than 1 copy of the same variable in the SV file if the upload button isn't pressed manually. If there are more than 1 of the same variable/data in the SV file, the addons will use the last (latest) copy of the variable/data. UniUploader will retrieve and append the data every time the upload button is pressed and (if option is set) when changes in the SV file are detected.
Upload Data Info
When UU uploads files, a few extra post variables are passed:
- the size of the uncompressed files are sent as integers, (# of bytes), only if gzip is turned on. For every checked SV, there will be a POST variable sent like this:
- usize_ + name of checked SV = # of bytes
- so if it were uploading a SV called myAddon.lua: usize_myAddon=123456
- usize_ + name of checked SV = # of bytes
- The local time of the computer running UU in both regular and UTC.
- The UU User Agent is passed via the HTTP Header, which also contains the UU Version.
Variable Snapshot
_REQUEST["usize_CharacterProfiler"] 712529 _REQUEST["clientTime"] 2007-08-09T19:06:09Z _REQUEST["clientTimeUTC"] 2007-08-09T23:06:09Z _POST["usize_CharacterProfiler"] 712529 _POST["clientTime"] 2007-08-09T19:06:09Z _POST["clientTimeUTC"] 2007-08-09T23:06:09Z _SERVER["HTTP_USER_AGENT"] UniUploader 2.0 (UU 2.6.7; English) _SERVER["CONTENT_TYPE"] multipart/form-data; boundary=698585d85ac04b7da6e40e52dc73542b _FILES["CharacterProfiler"] Array ( [name] => CharacterProfiler.lua [type] => application/octet-stream [tmp_name] => C:\DOCUME~1\Matt\LOCALS~1\Temp\php\upload\php56.tmp [error] => 0 [size] => 712529 )
Raw Data
This is a reassembled UniUploader TCP data stream with the binary data cut out:
POST /info.php HTTP/1.1 User-Agent: UniUploader 2.0 (UU 2.6.7; English) Content-Type: multipart/form-data; boundary=e62f89ca2c714e0dac26d9c465641710 Accept: application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Content-Length: 110174 Connection: Keep-Alive Host: foolyfrag.com --e62f89ca2c714e0dac26d9c465641710 Content-Disposition: form-data; name="usize_FuBar" 1101 --e62f89ca2c714e0dac26d9c465641710 Content-Disposition: form-data; name="FuBar"; filename="FuBar.lua.gz" Content-Type: application/octet-stream *BINARY DATA REMOVED FOR WIKI* --e62f89ca2c714e0dac26d9c465641710 Content-Disposition: form-data; name="usize_PvPLog" 38319 --e62f89ca2c714e0dac26d9c465641710 Content-Disposition: form-data; name="PvPLog"; filename="PvPLog.lua.gz" Content-Type: application/octet-stream *BINARY DATA REMOVED FOR WIKI* --e62f89ca2c714e0dac26d9c465641710 Content-Disposition: form-data; name="usize_CharacterProfiler" 712529 --e62f89ca2c714e0dac26d9c465641710 Content-Disposition: form-data; name="CharacterProfiler"; filename="CharacterProfiler.lua.gz" Content-Type: application/octet-stream *BINARY DATA REMOVED FOR WIKI* --e62f89ca2c714e0dac26d9c465641710 Content-Disposition: form-data; name="clientTime" 2007-08-09T19:28:20Z --e62f89ca2c714e0dac26d9c465641710 Content-Disposition: form-data; name="clientTimeUTC" 2007-08-09T23:28:20Z --e62f89ca2c714e0dac26d9c465641710--
Screenshot Protocol
- UU posts OPERATION=CHECKSHOTS and data={a '\n' separated list of md5 hashes of the screenshots }
- Interface responds with which a '\n' separated list of md5 hashes for screenshots not uploaded yet
- UU posts OPERATION=UPSHOTS and the screenshot files (.jpg) to the same url.
All of this happens with the Primary Interface URL (the one that shows up on first tab in UU) The contents of the PHP variable $_FILES after the post is complete in step 3 could be:
Array ( [ef1c521103e556db3fd2bca88c83bdea] => Array ( [name] => WoWScrnShot_080908_155425.jpg [type] => application/octet-stream [tmp_name] => /data/tmp/phpvhE5Wb [error] => 0 [size] => 276956 ) )
Example Screenshot Interface Script:
<?php // CREATE TABLE `screenshots` ( // `id` INT( 11 ) NOT NULL AUTO_INCREMENT , // `fingerprint` VARCHAR( 32 ) NOT NULL , // `data` LONGBLOB NOT NULL , // PRIMARY KEY ( `id` ) // ) ENGINE = MYISAM $op=get_var("OPERATION"); $db=mysql_connect("localhost", "??????", "??????"); mysql_select_db("test",$db); switch($op){ case 'CHECKSHOTS': check_shots(); break; case 'UPSHOTS': up_shots(); break; default: break; } function up_shots(){ global $db; //print_r($_FILES); foreach($_FILES as $file){ //do whatever with them //always insert into db so user does not have to upload same screenshots again indefinitley } } function check_shots(){ $data = get_var("data"); $rows = explode("\n",$data); $donthaveyet = array(); foreach($rows as $row){ if (!doihave($row)){ $donthaveyet[] = $row; } } $out = implode("\n",$donthaveyet); echo $out; } function doihave($fingerprint){ global $db; $result = mysql_query("select * from screenshots where fingerprint='".$fingerprint."'",$db); return (mysql_num_rows($result)< 1) ? false : true; } function get_var($var){ $out = ''; if (isset($_POST[$var])) $out = $_POST[$var]; if (isset($_REQUEST[$var])) $out = $_REQUEST[$var]; return $out; } ?>