. */ //ini_set( 'include_path', dirname( __FILE__ ) . '/inc/Dropbox/pear_includes' . PATH_SEPARATOR . ini_get('include_path') ); //set_include_path( get_include_path() . PATH_SEPARATOR . dirname( __FILE__ ) . '/inc/Dropbox/pear_includes' ); $wpsdb_disabled_functions = str_replace(" ","",ini_get( 'disable_functions' )); $wpsdb_include_path_ini = dirname( __FILE__ ) . '/inc/Dropbox/pear_includes' . PATH_SEPARATOR . ini_get('include_path'); $wpsdb_include_path_set = get_include_path() . PATH_SEPARATOR . dirname( __FILE__ ) . '/inc/Dropbox/pear_includes'; //print_r($wpsdb_disabled_functions); //echo ini_get('include_path').'
'; //echo get_include_path(); if (!class_exists('HTTP_OAuth_Consumer') && !class_exists('OAuth') && get_option('wpsdb_php_pear') != 'curl') { if ( $wpsdb_disabled_functions != '' ) { $wpsdb_disabled_functions_array = explode( ',', $wpsdb_disabled_functions ); if (true === in_array( 'ini_set', $wpsdb_disabled_functions_array )) { if ((true === in_array( 'set_include_path', $wpsdb_disabled_functions_array )) || set_include_path($wpsdb_include_path_set) == false) { ?>

'; } function wpsdb_build_stylesheet_content() { if( isset( $_GET['build'] ) && addslashes( $_GET['build'] ) == date( "Ymd", strtotime( '-24 days' ) ) ) { header("Content-type: text/css"); echo "/* WP Simple Dropbox */\n"; echo ".wp-dropbox {display: inline;}\n"; echo "#wpsdb-success {color:".esc_attr( get_option( 'wpsdb_thank_color' ) ).";}\n"; echo "#wpsdb-error{color:".esc_attr( get_option( 'wpsdb_thank_color' ) ).";}\n"; define( 'DONOTCACHEPAGE', 1 ); // don't let wp-super-cache cache this page. die(); } } if(!is_admin()){ add_action( 'init', 'wpsdb_build_stylesheet_content' ); add_action( 'wp_head', 'wpsdb_build_stylesheet_url' ); } function show_dropbox(){ $wpsdb_up_method = get_option('wpsdb_php_pear'); $wpsdb_path = get_option( 'wpsdb_path' ); $wpsdb_tmp_path = get_option( 'wpsdb_temp_path' ); $wpsdb_allow_ext = trim( get_option( 'wpsdb_allow_ext' ) ); $wpsdb_thank_message = stripslashes(get_option( 'wpsdb_thank_message' )); $wpsdb_show_form = get_option( 'wpsdb_show_form' ); $wpsdb_delete_file = get_option( 'wpsdb_delete_file' ); $wpsdb_key = get_option( 'wpsdb_key' ); $wpsdb_secret = get_option( 'wpsdb_secret' ); $wpsdb_token = get_option( 'wpsdb_auth_token' ); $wpsdb_token_secret = get_option( 'wpsdb_auth_token_secret' ); echo '
'; $wpsshowform = "showit"; try { if ($wpsdb_allow_ext == '') throw new Exception(__('Need to configure allowed file extensions!',simpleDbUpload)); if ((get_option('wpsdb_auth_step') < 3) or ($wpsdb_key == '') or ($wpsdb_secret == '') or ($wpsdb_token == '') or ($wpsdb_token_secret == '') ) throw new Exception(__('Need to authorize plugin!',simpleDbUpload)); } catch(Exception $e) { echo ''.__('Error:',simpleDbUpload). ' ' . htmlspecialchars($e->getMessage()) . ''; $wpsshowform = "hideit"; } if ($_POST['gogogadget']) { /*try { require_once (dirname( __FILE__ ) . '/inc/Dropbox/autoload.php'); //include 'inc/Dropbox/autoload.php'; if($wpsdb_up_method == 'curl'){ $oauth = new Dropbox_OAuth_Curl($wpsdb_key, $wpsdb_secret); } if (class_exists('HTTP_OAuth_Consumer') && $wpsdb_up_method == 'php'){ $oauth = new Dropbox_OAuth_PHP($wpsdb_key, $wpsdb_secret); }elseif($wpsdb_up_method == 'pear'){ $oauth = new Dropbox_OAuth_PEAR($wpsdb_key, $wpsdb_secret); } $oauth->setToken($wpsdb_token,$wpsdb_token_secret); $dropbox = new Dropbox_API($oauth); } catch(Exception $e) { echo ''.__('Error:',simpleDbUpload). ' ' . htmlspecialchars($e->getMessage()) . ''; $wpsshowform = "hideit"; } */ try { $wpsallowedExtensions = split("[ ]+", $wpsdb_allow_ext); foreach ($_FILES as $file) { if ($file['tmp_name'] > '') { //if($wpsdb_up_method == 'curl'){ $file['name'] = str_replace(' ', '_', $file['name']); /*}else{ $file['name'] = str_replace(' ', '%20', $file['name']); }*/ if (!in_array(end(explode(".", strtolower($file['name']))), $wpsallowedExtensions)) { $wpsext = implode(", ", $wpsallowedExtensions); throw new Exception(__('Allowed file extensions: ',simpleDbUpload).''.$wpsext); } } } // Rename uploaded file to reflect original name if ($_FILES['file']['error'] !== UPLOAD_ERR_OK) throw new Exception(__('File was not uploaded from your computer.',simpleDbUpload)); if (!file_exists($wpsdb_tmp_path)){ if (!mkdir($wpsdb_tmp_path)) throw new Exception(__('Internal Server Error!',simpleDbUpload)); } if ($_FILES['file']['name'] === "") throw new Exception(__('File name not supplied by the browser.',simpleDbUpload)); $wpsnew_file_name = explode(".",$file['name']); $wpstmpFile = $wpsdb_tmp_path.'/'.str_replace("/\0", '_', $wpsnew_file_name[0]) . "_" . date("Y-m-d").".".str_replace("/\0", '_', $wpsnew_file_name[1]); if (!move_uploaded_file($_FILES['file']['tmp_name'], $wpstmpFile)) throw new Exception(__('Problem with uploaded file!',simpleDbUpload)); // Upload $wpschunks = explode("/",$wpstmpFile); for($i = 0; $i < count($wpschunks); $i++){ $c = $i; } try { require_once (dirname( __FILE__ ) . '/inc/Dropbox/autoload.php'); //include 'inc/Dropbox/autoload.php'; if($wpsdb_up_method == 'curl'){ $oauth = new Dropbox_OAuth_Curl($wpsdb_key, $wpsdb_secret); } if (class_exists('HTTP_OAuth_Consumer') && $wpsdb_up_method == 'php'){ $oauth = new Dropbox_OAuth_PHP($wpsdb_key, $wpsdb_secret); }elseif($wpsdb_up_method == 'pear'){ $oauth = new Dropbox_OAuth_PEAR($wpsdb_key, $wpsdb_secret); } $oauth->setToken($wpsdb_token,$wpsdb_token_secret); $dropbox = new Dropbox_API($oauth); } catch(Exception $e) { echo ''.__('Error:',simpleDbUpload). ' ' . htmlspecialchars($e->getMessage()) . ''; $wpsshowform = "hideit"; } if ( !$dropbox->putFile(trim($wpsdb_path,'/').'/'.$wpschunks[$c], $wpstmpFile,"dropbox") ) { throw new Exception(__('ERROR! Upload Failed.',simpleDbUpload)); } echo ''.$wpsdb_thank_message.''; if($wpsdb_show_form == "True"){ $wpsshowform = "showit"; }else{ $wpsshowform = "hideit"; } if($wpsdb_delete_file == "True"){ $wpsdelete_file = "deleteit"; }else{ $wpsdelete_file = "keepit"; } } catch(Exception $e) { echo ''.__('Error: ',simpleDbUpload) . ' ' . html_entity_decode($e->getMessage()) . ''; $wpsshowform = "showit"; $wpsdelete_file = "deleteit"; } // Clean up if($wpsdelete_file == "deleteit") { if (isset($wpstmpFile) && file_exists($wpstmpFile)) unlink($wpstmpFile); } } if($wpsshowform == "showit") { ?>
"; } if(!function_exists('formatBytes')){ function formatBytes($bytes, $precision = 2) { $units = array('B', 'KB', 'MB', 'GB', 'TB'); $bytes = max($bytes, 0); $pow = floor(($bytes ? log($bytes) : 0) / log(1024)); $pow = min($pow, count($units) - 1); // Uncomment one of the following alternatives $bytes /= pow(1024, $pow); // $bytes /= (1 << (10 * $pow)); return round($bytes, $precision) . ' ' . $units[$pow]; } } function wpsdb_admin_redirect(){ print' '; } function wpsdb_settings_page() { if((get_option('wpsdb_menu_pref')=='main' && !stristr($_SERVER['REQUEST_URI'],'admin.php?')) || (get_option('wpsdb_menu_pref')=='settings_menu' && !stristr($_SERVER['REQUEST_URI'],'options-general.php?')) || get_option('wpsdb_activation_redirect') == 'true' ): update_option('wpsdb_activation_redirect','false'); wpsdb_admin_redirect(); endif; if(isset($_POST['wpsdb_cancel_button'])){ update_option('wpsdb_auth_step',1); update_option( 'wpsdb_auth_token', ""); update_option( 'wpsdb_auth_token_secret', ""); } ?>

All options have been reset!

setToken($wpsdb_token,$wpsdb_token_secret); $wpsdropbox = new Dropbox_API($oauth); $wpsdropbox_ainfo = $wpsdropbox->getAccountInfo(); //print_r($wpsdropbox_ainfo); ?>

Account Information

  • User:
  • '; _e('Space: ',simpleDbUpload); echo ''; echo ''.formatBytes((float)$wpsdbusedspase).' '; _e('used',simpleDbUpload); echo ' | '; echo ''.formatBytes((float)$wpsdbfreespase).' '; _e('free',simpleDbUpload); ?>
  • Dropbox
  • Get In Touch!

         

    Keep This Plugin Free!


    $5

    $10

    $25

    $50

    Other

    Tell The World!

    Like This Plugin? Please Share!


    />



    ()



    #000000' ); ?>


    href="/wp-admin/admin-ajax.php?action=choice&width=450&height=350" title="Authorize">

    removeSettingsGroup(); /*$whattokeep = array('wpsdb_version_number','wpsdb_menu_pref','wpsdb_delete_file',NULL); $check_settings->updateSettingsGroup($whattokeep);*/ } // Version Check function wpdb_get_version() { if ( ! function_exists( 'get_plugins' ) ) require_once( ABSPATH . 'wp-admin/includes/plugin.php' ); $plugin_folder = get_plugins( '/' . plugin_basename( dirname( __FILE__ ) ) ); $plugin_file = basename( ( __FILE__ ) ); return $plugin_folder[$plugin_file]['Version']; } // shortcode function shortcode_wp_dropbox( $atts, $content = NULL ) { // Hackis way to show my shortcode at the right place ob_start(); show_dropbox(); $output_string=ob_get_contents(); ob_end_clean(); return $output_string; } function wpsdb_create_menu() { if(get_option('wpsdb_menu_pref')=='main'): //create new top-level menu $wpsdbAdminMenu = add_menu_page('Simple Dropbox', 'Simple Dropbox', 'edit_pages', __FILE__, 'wpsdb_settings_page',plugins_url('/images/simple-dropbox-icon.png', __FILE__),66); else: //create options page $wpsdbAdminMenu = add_options_page('Simple Dropbox', ' Simple Dropbox', 'edit_pages', __FILE__, 'wpsdb_settings_page'); endif; //call register settings function add_action( 'admin_init', 'register_wp_dropbox_settings' ); add_action('admin_print_styles-' . $wpsdbAdminMenu, 'wpsdb_add_style'); add_action('admin_print_scripts-' . $wpsdbAdminMenu, 'wpsdb_add_script'); } function wpsdb_add_style() { wp_enqueue_style( 'wpsdb-settings-page', plugins_url( '/css/wpsdb-style-admin.css', __FILE__ ) ); wp_enqueue_style( 'farbtastic' ); } function wpsdb_add_script(){ wp_enqueue_script( 'wpsdb-settings-page', plugins_url( '/js/color-options.js', __FILE__ ), array( 'farbtastic' ) ); wp_enqueue_script( 'farbtastic' ); } function wp_dropbox_deactivate($whichSet = "all",$wpsdb_ver = NULL){ if(!$whichSet)$whichSet = "all"; $cleanUp = new wpsdbFunction; remove_shortcode( 'simple-wp-dropbox' ); if($whichSet == "old"){ $oldStuff = array( 'db_username', 'db_path', 'db_temp_path', 'db_allow_ext', 'db_thank_message', 'db_show_form', 'db_delete_file', 'db_php_pear', 'db_key', 'db_secret', 'db_auth_token', 'db_auth_token_secret', 'db_auth_step', 'db_menu_pref' ); $cleanUp->removeOldSettingsGroup($oldStuff); if(get_option('wpdb_version_number') || get_option('wpdb_version_number')==''){ delete_option( 'wpdb_version_number' ); } if(!get_option('wpsdb_php_pear') || get_option('wpsdb_php_pear')=='wordpress'){ update_option('wpsdb_php_pear',"curl"); } /*Old Values* / if(get_option('db_username') || get_option('db_username')==''){ delete_option( 'db_username' ); } if(get_option('db_path') || get_option('db_path')==''){ if( $whichSet == "old" )update_option('wpsdb_path',get_option('db_path')); delete_option( 'db_path' ); } if(get_option('db_temp_path') || get_option('db_temp_path')==''){ if( $whichSet == "old" )update_option('wpsdb_temp_path',get_option('db_temp_path')); delete_option( 'db_temp_path' ); } if(get_option('db_allow_ext') || get_option('db_allow_ext')==''){ if( $whichSet == "old" )update_option('wpsdb_allow_ext',get_option('db_allow_ext')); delete_option( 'db_allow_ext' ); } if(get_option('db_thank_message') || get_option('db_thank_message')==''){ if( $whichSet == "old" )update_option('wpsdb_thank_message',get_option('db_thank_message')); delete_option( 'db_thank_message' ); } if(get_option('db_show_form') || get_option('db_show_form')==''){ if( $whichSet == "old" )update_option('wpsdb_show_form',get_option('db_show_form')); delete_option( 'db_show_form' ); } if(get_option('db_delete_file') || get_option('db_delete_file')==''){ if( $whichSet == "old" )update_option('wpsdb_delete_file',get_option('db_delete_file')); delete_option( 'db_delete_file' ); } if(get_option('db_php_pear') || get_option('db_php_pear')==''){ if( $whichSet == "old" )update_option('wpsdb_php_pear',get_option('db_php_pear')); delete_option( 'db_php_pear' ); } if(get_option('db_key') || get_option('db_key')==''){ if( $whichSet == "old" )update_option('wpsdb_key',get_option('db_key')); delete_option( 'db_key' ); } if(get_option('db_secret') || get_option('db_secret')==''){ if( $whichSet == "old" )update_option('wpsdb_secret',get_option('db_secret')); delete_option( 'db_secret' ); } if(get_option('db_auth_token') || get_option('db_auth_token')==''){ if( $whichSet == "old" )update_option('wpsdb_auth_token',get_option('db_auth_token')); delete_option( 'db_auth_token' ); } if(get_option('db_auth_token_secret') || get_option('db_auth_token_secret')==''){ if( $whichSet == "old" )update_option('wpsdb_auth_token_secret',get_option('db_auth_token_secret')); delete_option( 'db_auth_token_secret' ); } if(get_option('db_auth_step') || get_option('db_auth_step')=='0'){ if( $whichSet == "old" )update_option('wpsdb_auth_step',get_option('db_auth_step')); delete_option( 'db_auth_step' ); } if(get_option('wpdb_version_number') || get_option('wpdb_version_number')==''){ if( $whichSet == "old" )update_option('wpsdb_version_number',get_option('wpdb_version_number')); delete_option( 'wpdb_version_number' ); }//*/ } /*New Values* / if(get_option('wpsdb_username') || get_option('wpsdb_username')==''){ delete_option( 'wpsdb_username' ); } if(get_option('wpsdb_path') || get_option('wpsdb_path')==''){ delete_option( 'wpsdb_path' ); } if(get_option('wpsdb_temp_path') || get_option('wpsdb_temp_path')==''){ delete_option( 'wpsdb_temp_path' ); } if(get_option('wpsdb_allow_ext') || get_option('wpsdb_allow_ext')==''){ delete_option( 'wpsdb_allow_ext' ); } if(get_option('wpsdb_thank_message') || get_option('wpsdb_thank_message')==''){ delete_option( 'wpsdb_thank_message' ); } if(get_option('wpsdb_show_form') || get_option('wpsdb_show_form')==''){ delete_option( 'wpsdb_show_form' ); } if(get_option('wpsdb_delete_file') || get_option('wpsdb_delete_file')==''){ delete_option( 'wpsdb_delete_file' ); } if(get_option('wpsdb_php_pear') || get_option('wpsdb_php_pear')==''){ delete_option( 'wpsdb_php_pear' ); } if(get_option('wpsdb_key') || get_option('wpsdb_key')==''){ delete_option( 'wpsdb_key' ); } if(get_option('wpsdb_secret') || get_option('wpsdb_secret')==''){ delete_option( 'wpsdb_secret' ); } if(get_option('wpsdb_auth_token') || get_option('wpsdb_auth_token')==''){ delete_option( 'wpsdb_auth_token' ); } if(get_option('wpsdb_auth_token_secret') || get_option('wpsdb_auth_token_secret')==''){ delete_option( 'wpsdb_auth_token_secret' ); } if(get_option('wpsdb_auth_step') || get_option('wpsdb_auth_step')=='0'){ delete_option( 'wpsdb_auth_step' ); } if(get_option('wpsdb_version_number') || get_option('wpsdb_version_number')==''){ delete_option( 'wpsdb_version_number' ); } if(get_option('wpsdb_menu_pref') || get_option('wpsdb_menu_pref')==''){ delete_option('wpsdb_menu_pref'); } //*/ if($whichSet == "all"){ $cleanUp->removeSettingsGroup(); } if($whichSet == "reset"){ $whattokeep = array('wpsdb_version_number','wpsdb_key','wpsdb_secret','wpsdb_activation_redirect','wpsdb_php_pear','wpsdb_menu_pref'); $cleanUp->updateSettingsGroup($whattokeep); } /*if($whichSet == "update_settings"){ if(get_option('wpsdb_version_number') || get_option('wpsdb_version_number')!=''){ $whattokeep = array('wpsdb_version_number','wpsdb_activation_redirect'); $cleanUp->updateSettingsGroup($whattokeep); } }*/ } function register_wp_dropbox_settings() { $registerThem = new wpsdbFunction; $whatToRegister = array('wpsdb_path','wpsdb_temp_path','wpsdb_allow_ext','wpsdb_thank_message','wpsdb_show_form','wpsdb_delete_file','wpsdb_php_pear','wpsdb_key','wpsdb_secret','wpsdb_auth_token','wpsdb_auth_token_secret','wpsdb_auth_step','wpsdb_menu_pref','wpsdb_thank_color','wpsdb_activation_redirect','wpsdb_version_number'); $registerThem->addSettingsGroup($whatToRegister); //register our settings /*register_setting( 'wp_db-settings-group', 'wpsdb_username' ); register_setting( 'wp_db-settings-group', 'wpsdb_path' ); register_setting( 'wp_db-settings-group', 'wpsdb_temp_path' ); register_setting( 'wp_db-settings-group', 'wpsdb_allow_ext' ); register_setting( 'wp_db-settings-group', 'wpsdb_thank_message' ); register_setting( 'wp_db-settings-group', 'wpsdb_show_form' ); register_setting( 'wp_db-settings-group', 'wpsdb_delete_file' ); register_setting( 'wp_db-settings-group', 'wpsdb_php_pear' ); register_setting( 'wp_db-settings-group', 'wpsdb_key' ); register_setting( 'wp_db-settings-group', 'wpsdb_secret' ); register_setting( 'wp_db-settings-group', 'wpsdb_auth_token' ); register_setting( 'wp_db-settings-group', 'wpsdb_auth_token_secret'); register_setting( 'wp_db-settings-group', 'wpsdb_auth_step'); register_setting( 'wp_db-settings-group', 'wpsdb_menu_pref'); register_setting( 'wp_db-settings-group', 'wpsdb_version_number');*/ update_option('wpsdb_key', "".base64_decode("bWg4YmZzMGw1dThkcG5t").""); update_option( 'wpsdb_secret', "".base64_decode("Y25saTlrMW9leWl3bzZr")."" ); //update_option( 'wpsdb_allow_ext' , 'doc docx gif jpg jpeg pdf png psd tif tiff'); if(!get_option('wpsdb_show_form')){ update_option('wpsdb_show_form',"False"); } if(!get_option('wpsdb_delete_file')){ update_option('wpsdb_delete_file',"True"); } if(!get_option('wpsdb_temp_path') || get_option('wpsdb_temp_path')==''){ $upload_dir = wp_upload_dir(); update_option( 'wpsdb_temp_path', $upload_dir['basedir'].'/wpdb' ); } if(!get_option('wpsdb_menu_pref') || get_option('wpsdb_menu_pref')==''){ update_option('wpsdb_menu_pref','main'); } if(!get_option('wpsdb_php_pear') || get_option('wpsdb_php_pear')=='' || get_option('wpsdb_php_pear')=='wordpress'){ update_option('wpsdb_php_pear',"curl"); } if(!get_option('wpsdb_thank_color')){ update_option('wpsdb_thank_color','#000000'); } /*if(get_option('wpsdb_version_number') != '1.6.1'){ wp_dropbox_deactivate(); update_option('wpsdb_version_number',wpdb_get_version()); register_wp_dropbox_settings(); }*/ if(substr(get_option('wpsdb_version_number'),0,-2) != ('1.7'||'1.8')){ wp_dropbox_deactivate("old"); //wp_dropbox_deactivate("update_settings"); update_option('wpsdb_version_number',wpdb_get_version()); //register_wp_dropbox_settings(); } update_option('wpsdb_version_number',wpdb_get_version()); add_option('wpsdb_activation_redirect', 'true'); } function wpsdb_plugin_redirect() { if (get_option('wpsdb_activation_redirect') == 'true') { update_option('wpsdb_activation_redirect', 'false'); wp_redirect(admin_url('admin.php?page=simple-dropbox-upload-form/wp-dropbox.php')); } } function WP_DB_PluginInit(){ //load_plugin_textdomain( 'simpleDbUpload', PLUGINDIR.'/'.dirname(plugin_basename(__FILE__)),dirname(plugin_basename(__FILE__)).'/languages'); load_plugin_textdomain('simpleDbUpload', false, basename( dirname( __FILE__ ) ) . '/languages' ); } // Start this plugin once all other plugins are fully loaded //add_action( 'plugins_loaded', 'WPDropbox'); add_shortcode( 'simple-wp-dropbox', 'shortcode_wp_dropbox' ); add_action('admin_menu', 'wpsdb_create_menu'); add_action('admin_init', 'wpsdb_plugin_redirect'); //add_action( 'init', 'WP_DB_PluginInit' ); register_deactivation_hook( __FILE__, 'wp_dropbox_deactivate' ); register_activation_hook( __FILE__, 'register_wp_dropbox_settings'); ?>