Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7fe514bed1
Fetching contributors…

Cannot retrieve contributors at this time

executable file 64 lines (56 sloc) 1.904 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
#!/usr/bin/perl -w

use strict;

use XML::TreePP;
use MIME::Base64;
use Data::Plist::BinaryReader;
my $reader=Data::Plist::BinaryReader->new();
my $backupdir=$ENV{HOME}."/Library/Application Support/MobileSync/Backup/";
opendir(DIR,$backupdir)|| terminate( "Could not open Backup dir: ".$@);
my $ts=0;
my $newest;
foreach (readdir(DIR)) {
    next if m/^\./;
    if((stat($backupdir.$_))[9]>$ts) {
        $newest=$_;
        $ts=(stat($backupdir.$_))[9];
    }
}
terminate( "Could not find any backups in ~/Library/Application Support/MobileSync")
    unless $newest;

use XML::TreePP;
my $tpp = XML::TreePP->new();
my $doc=$tpp->parsefile($backupdir.$newest.'/Manifest.plist');
my $blob=$doc->{plist}->{dict}->{data}->[2] || die('Could not parse manifest. Invalid XML data?');
my $plist_data=$reader->open_string(decode_base64($blob))->data;

my @apps;
foreach my $app (keys %{$plist_data->{Applications}}) {
    push @apps, make_short( $plist_data->{Applications}->{$app}->{AppInfo}->{CFBundleDisplayName}||
         $plist_data->{Applications}->{$app}->{AppInfo}->{CFBundleExecutable});
}
my $data='-F apps='.join(' -F apps=',@apps);
my $res=`curl -s -H \"Expect:\" $data http://iphone.iusethis.com/profile/send`;

if ($res =~ m/^\d+$/) {
system('open','http://iphone.iusethis.com/profile/view/'.$res.'?match=1');
terminate("Profile uploaded. Please check your browser");
} else
{
terminate('Unable to send profile to server '.$res);
}

sub terminate {
    my $message=shift;
# osascript -l AppleScript -e 'tell Application "Finder" to display alert "Call Frank" '
system('osascript -l AppleScript -e \'tell Application "Finder" to display alert "'.$message.'" \'');
exit
}

sub make_short {
    my ($name)=@_;
    $name =~ s/[^\w\@\-]//g;
    return lc $name;
}

sub simple_escape {
my $text=shift;
#FIXME: this sucks
$text =~ s/\&/\&/g;
$text =~ s/\s/\%20/g;
return $text;
}
Something went wrong with that request. Please try again.