
Tutaj wrzucam kod źródłowy :
dbouploader.php
<?php /* Plugin Name: DboUploader - Dropbox upload Plugin URI: <a href="http://www.webania.net/dbouploader/" target="_blank">http://www.webania.net/dbouploader/</a> Description: Upload to Dropbox Version: 1.0 Author: Elvin Haci Author URI: <a href="http://www.webania.net" target="_blank">http://www.webania.net</a> License: GPL2 */ /* Copyright 2011, Elvin Haci (email : elvinhaci@hotmail.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, version 2, as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ function dbouploader($content = '') { if (is_user_logged_in()) add_shortcode('dbouploader', 'shortcoder'); else add_shortcode('dbouploader', 'notloggedin'); return $content; } function notloggedin($atts,$content = '') { return 'You must be logged in!'; } function shortcoder($atts,$content = '') { ////////////////// if ($_POST) { try { // Rename uploaded file to reflect original name if ($_FILES['file']['error'] !== UPLOAD_ERR_OK) throw new Exception('File was not successfully uploaded from your computer.'); throw new Exception('File size is too large or file type is not supported.'); throw new Exception('Cannot create temporary directory!'); if ($_FILES['file']['name'] === "") throw new Exception('File name not supplied by the browser.'); get_currentuserinfo(); $tmpFile = $tmpDir.'/'.str_replace("/\0", '_', $current_user->user_email.'_'.$_FILES['file']['name']); throw new Exception('Cannot rename uploaded file!'); // Enter your Dropbox account credentials here $uploader = new DropboxUploader($dropbox_email, $dropbox_password); $uploader->upload($tmpFile, $_POST['dest']); return '<span style="color: green;font-weight:bold;margin-left:0px;">File successfully uploaded. Thank you!</span>'; } catch(Exception $e) { return '<span style="color: red;font-weight:bold;margin-left:0px;">Error: ' . htmlspecialchars($e->getMessage()) . '</span>'; } // Clean up } else { return ' <div class="box" align="center"> <h1>Dropbox Uploader Demo<br> </h1> <form method="POST" enctype="multipart/form-data"> <input type="file" name="file" /><br><br> <input type="submit" value="Upload your file!" /> <input style="display:none" type="text" name="dest" value="'.$dropbox_folder.'" /> </div> '; } //////////////// } add_action('the_content', 'dbouploader'); ?>