1. UU posts OPERATION=CHECKSHOTS and data={a '\n' separated list of md5 hashes of the screenshots }
2. Interface responds with which a '\n' separated list of md5 hashes for screenshots not uploaded yet
3. UU posts OPERATION=UPSHOTS and the screenshot files (.jpg) to the same url.
All of this only 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:
- Code: Select all
{Array
(
[ef1c521103e556db3fd2bca88c83bdea] => Array
(
[name] => WoWScrnShot_080908_155425.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phpvhE5Wb
[error] => 0
[size] => 276956
)
[2c8d6246ac055ae73f16732cabffa6c3] => Array
(
[name] => WoWScrnShot_070908_193502.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phpkychLn
[error] => 0
[size] => 219529
)
[b6f1b8513db505c1020b9a5dd7564644] => Array
(
[name] => WoWScrnShot_070908_123015.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phpBlm81H
[error] => 0
[size] => 279754
)
[39eba34370e3f807f21ad1f4d648ef6d] => Array
(
[name] => WoWScrnShot_072108_153128.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phpslVrFc
[error] => 0
[size] => 257439
)
[fb375723cac8987467fa0aefca1dfffd] => Array
(
[name] => WoWScrnShot_081408_184603.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phpHGScxQ
[error] => 0
[size] => 263177
)
[1c36c83b9d8a1fbe62800a749acaca8b] => Array
(
[name] => WoWScrnShot_072908_165635.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phpoH67OD
[error] => 0
[size] => 265767
)
[bf3c4e2b3b394d53711f40964123e248] => Array
(
[name] => WoWScrnShot_080908_155427.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phphJUyDA
[error] => 0
[size] => 277724
)
[84533f8745cc8be0d933538d92b64444] => Array
(
[name] => WoWScrnShot_070908_130729.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phpsypXmH
[error] => 0
[size] => 238509
)
[e861ee80f47a556b7cc708433345db3a] => Array
(
[name] => WoWScrnShot_070908_175043.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phplG698W
[error] => 0
[size] => 210960
)
[e2c89b7fed66a04f01d3297c22a40b2e] => Array
(
[name] => WoWScrnShot_071608_164046.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phpCSNquk
[error] => 0
[size] => 259982
)
[05c4cbc15a9da3101ac505daf8a9a328] => Array
(
[name] => WoWScrnShot_071508_003950.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phpFiYjXR
[error] => 0
[size] => 239832
)
[f4567f52e44f29f867dffc9e8f533c87] => Array
(
[name] => WoWScrnShot_072908_165426.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/php0HxM1x
[error] => 0
[size] => 228742
)
[6ac7694044d49a996742f37996c03e4e] => Array
(
[name] => WoWScrnShot_071508_003942.jpg
[type] => application/octet-stream
[tmp_name] => /data/tmp/phpVnPBfm
[error] => 0
[size] => 245675
)
)
}
Here is a script I made for testing:
- Code: Select all
<?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;
}
?>