Advertisement
fortin

alfred-pastebin-anon.php

Mar 22nd, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. #!/usr/bin/php
  2. // requires growlnotify and a Keychain entry for your dev key
  3.  
  4. <?php
  5. $paste                  = shell_exec("pbpaste"); // grab clipboard contents
  6. $api_user_key           = "";       // blank session key
  7. $api_dev_key            = shell_exec('security find-generic-password -wl "Pastebin dev key" | tr -d "\\n"'); // grabs api_developer_key from keychain
  8. $api_paste_code         = $paste; // your paste text
  9. $api_paste_name         = $argv[1]; // name or title of your paste
  10. $api_paste_format       = $argv[2]; // syntax of paste
  11. $api_paste_expire_date  = $argv[3]; // expiry date for paste
  12. $api_paste_private      = $argv[4]; // 0=public 1=unlisted 2=private
  13. $api_paste_name         = urlencode($api_paste_name);
  14. $api_paste_code         = urlencode($api_paste_code);
  15.  
  16. $url                    = 'https://pastebin.com/api/api_post.php';
  17. $ch                     = curl_init($url);
  18.  
  19. if (empty($api_paste_code)) {
  20.     exit("Clipboard empty!");
  21. } elseif (empty($api_paste_name)) {
  22.     exit("Title missing!");
  23. } elseif (empty($api_paste_format)) {
  24.     exit("Format missing!");
  25. } elseif (empty($api_paste_expire_date)) {
  26.     $api_paste_expire_date = '10M';
  27.     shell_exec("/usr/local/bin/growlnotify --appIcon Pastebin -m 'Paste expires in 10!'");
  28. }
  29.  
  30. if (empty($api_paste_private)) {
  31.     $api_paste_private  = '2'; // default privacy setting 'Private'
  32. }
  33.  
  34. curl_setopt($ch, CURLOPT_POST, true);
  35. curl_setopt($ch, CURLOPT_POSTFIELDS, 'api_option=paste&api_user_key='.$api_user_key.'&api_paste_private='.$api_paste_private.'&api_paste_name='.$api_paste_name.'&api_paste_expire_date='.$api_paste_expire_date.'&api_paste_format='.$api_paste_format.'&api_dev_key='.$api_dev_key.'&api_paste_code='.$api_paste_code.'');
  36. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  37. curl_setopt($ch, CURLOPT_VERBOSE, 1);
  38. curl_setopt($ch, CURLOPT_NOBODY, 0);
  39.  
  40. $response               = curl_exec($ch);
  41. echo $response;
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement