<? } elseif($dropCom == "connected") { // der nutzer ist eingelogged //nun können dateien hochgeladen werden try { $consumerKey = '5wty9mf06gcuco0'; $consumerSecret = 'hveok3hllw48hji'; $oauth = new \Dropbox_OAuth_PEAR( $consumerKey, $consumerSecret ); $dropbox = new \Dropbox_API( $oauth,\Dropbox_API::ROOT_SANDBOX ); $oauth->setToken( $_SESSION['oauth_tokens'] ); $accInfo= $dropbox->getAccountInfo(); } catch (\DropboxException $e) { echo "Es ist ein Fehler aufgetreten, bitte laden Sie die Seite neu."; die(); } ?> <ul data-role="listview" data-inset="true" data-theme="e"> <li> <h1>Verbundener Dropbox Account</h1> <fieldset class="ui-grid-a"> <div class="ui-block-a" style="font-size:10pt;font-weight:normal;">Name:<br>Mail:</div> <div class="ui-block-b" style="font-size:10pt;font-weight:normal;"><?=$accInfo["display_name"] ?> <br><?=$accInfo["email"] ?> </div> </fieldset> </li>
function wpsdb_settings_page() { //global $wpsdb_oauth; 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(); } if (isset($_POST['wpsdb_cancel_button'])) { update_option('wpsdb_auth_step', 1); update_option('wpsdb_auth_token', ""); update_option('wpsdb_auth_token_secret', ""); } ?> <script type="text/javascript"> function displaymessage() { var retVal = confirm("Are you sure?"); if( retVal == true ){ tb_remove(); document.body.innerHTML += '<form id="dynForm" action="<?php if (get_option('wpsdb_menu_pref') != 'main') { echo get_option('siteurl') . "/wp-admin/options-general.php?page=simple-dropbox-upload-form/wp-dropbox.php"; } else { echo get_option('siteurl') . "/wp-admin/admin.php?page=simple-dropbox-upload-form/wp-dropbox.php"; } ?> " method="post"><input type="hidden" name="wpsdb_cancel_button" value="true"></form>'; document.getElementById("dynForm").submit(); return true; }else{ return false; } } </script> <div id="fb-root"></div> <script>(function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=301652803267448"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); </script> <?php if (isset($_POST['wpsdb_submit_hidden'])) { if ($_POST['wpsdb_submit_hidden'] == 'Y') { if (wp_verify_nonce($_POST['wpsdb_set_nonce'], plugin_basename(__FILE__))) { // Save the posted value in the database update_option('wpsdb_path', trim($_POST['wpsdb_path'], '/') . '/'); update_option('wpsdb_temp_path', $_POST['wpsdb_temp_path']); update_option('wpsdb_allow_ext', $_POST['wpsdb_allow_ext']); update_option('wpsdb_thank_message', $_POST['wpsdb_thank_message']); update_option('wpsdb_redirect_page', $_POST['wpsdb_redirect_page']); update_option('wpsdb_show_progress', $_POST['wpsdb_show_progress']); update_option('wpsdb_show_multi', $_POST['wpsdb_show_multi']); update_option('wpsdb_multi_link_text', $_POST['wpsdb_multi_link_text'] == '' ? 'Multiple Files? Click Here!' : $_POST['wpsdb_multi_link_text']); update_option('wpsdb_show_multi_size', $_POST['wpsdb_show_multi_size']); update_option('wpsdb_show_form', $_POST['wpsdb_show_form']); update_option('wpsdb_delete_file', $_POST['wpsdb_delete_file']); update_option('wpsdb_thank_color', $_POST['wpsdb_thank_color']); update_option('wpsdb_php_pear', $_POST['wpsdb_php_pear']); if (!empty($_POST['wpsdb_allow_ext']) && get_option('wpsdb_auth_step') == 0) { update_option('wpsdb_auth_step', 1); } if (isset($_POST['wpsdb_menu_pref'])) { if ($_POST['wpsdb_menu_pref'] == 'settings_menu' and get_option('wpsdb_menu_pref') != 'settings_menu') { update_option('wpsdb_menu_pref', 'settings_menu'); wpsdb_admin_redirect(); } } if (!isset($_POST['wpsdb_menu_pref'])) { if (empty($_POST['wpsdb_menu_pref']) and get_option('wpsdb_menu_pref') != 'main') { update_option('wpsdb_menu_pref', 'main'); wpsdb_admin_redirect(); } } if (isset($_POST['wpsdb_reset_confirm']) and isset($_POST['wpsdbreset']) and trim($_POST['wpsdb_reset_confirm']) == trim($_POST['wpsdbreset'])) { wp_dropbox_deactivate('reset'); register_wp_dropbox_settings(); $wpsreset = true; ?> <div class="updated"> <p><strong>All options have been reset!</strong></p> </div> <?php wpsdb_admin_redirect(); } } else { wpsdb_admin_redirect(); } } } // Put an options updated message on the screen if (isset($_POST['wpsdb_submit_hidden'])) { //if ($_POST[ "wpsdb_submit_hidden" ] == 'Y' && !$wpsdb_error && !$wpsreset) { if ($_POST["wpsdb_submit_hidden"] == 'Y' && empty($wpsdb_error) && empty($wpsreset)) { ?> <div class="updated fade"> <p> <strong><?php _e('Options saved.', 'simpleDbUpload'); ?> </strong> </p> </div> <?php } } ?> <div class="wrap"> <div id="wpsdb-header"> <div id="wpsdb-title"> <h2><?php _e('Simple Dropbox Upload', 'simpleDbUpload'); ?> <p id="wpsdb-sub-title"><?php _e('This plugin will create a folder in your Dropbox account and allow public uploads.', 'simpleDbUpload'); ?> </p></h2> </div> <!--div id="wpsdb-sub-title"> <p><?php _e('This plugin will create a folder in your Dropbox account and allow public uploads.', 'simpleDbUpload'); ?> </p> </div--> </div> <?php /* // Put an options updated message on the screen if(isset($_POST[ 'wpsdb_submit_hidden' ])): //if ($_POST[ "wpsdb_submit_hidden" ] == 'Y' && !$wpsdb_error && !$wpsreset) { if ($_POST[ "wpsdb_submit_hidden" ] == 'Y' && empty($wpsdb_error) && empty($wpsreset)) { ?> <div class="updated fade"> <p> <strong><?php _e('Options saved.', 'simpleDbUpload' ); ?></strong> </p> </div> <?php } endif;*/ ?> <div id="poststuff" class="metabox-holder has-right-sidebar" style="margin-top:85px"> <!-- BEGIN SIDEBAR --> <div id="side-info-column" class="inner-sidebar"> <?php if (get_option('wpsdb_auth_step') == 3) { //if(false): $consumerKey = get_option('wpsdb_key'); $consumerSecret = get_option('wpsdb_secret'); include 'inc/Dropbox/autoload.php'; $oauth = new Dropbox_OAuth_Wordpress($consumerKey, $consumerSecret); $wpsdb_token = get_option('wpsdb_auth_token'); $wpsdb_token_secret = get_option('wpsdb_auth_token_secret'); $oauth->setToken($wpsdb_token, $wpsdb_token_secret); $wpsdropbox = new Dropbox_API($oauth); $wpsdropbox_ainfo = $wpsdropbox->getAccountInfo(); //print_r($wpsdropbox_ainfo); ?> <div class="meta-box-sortables"> <div id="about" class="postbox"> <h3 class="hndle" id="about-sidebar">Account Information</h3> <div class="inside"> <p> <li><strong>User:</strong> <?php echo $wpsdropbox_ainfo['email']; ?> </li> <li><?php $wpsdbfreespase = $wpsdropbox_ainfo['quota_info']['quota'] - ($wpsdropbox_ainfo['quota_info']['normal'] - $wpsdropbox_ainfo['quota_info']['shared']); $wpsdbusedspase = $wpsdropbox_ainfo['quota_info']['normal'] + $wpsdropbox_ainfo['quota_info']['shared']; echo '<strong>'; _e('Space: ', 'simpleDbUpload'); echo '</strong>'; echo '<strong>' . formatBytes((double) $wpsdbusedspase) . '</strong> '; _e('used', 'simpleDbUpload'); echo ' | '; echo '<strong>' . formatBytes((double) $wpsdbfreespase) . '</strong> '; _e('free', 'simpleDbUpload'); ?> </li> <li><a href="https://www.dropbox.com/home/<?php echo get_option('wpsdb_path'); ?> " target="_blank">Dropbox</a></li> </p> </div> </div> </div> <?php } ?> <div class="meta-box-sortables"> <div id="about" class="postbox"> <h3 class="hndle" id="about-sidebar">Get In Touch!</h3> <div class="inside"> <p> <a href="http://www.facebook.com/creativedesignsolutionsinc" target="_blank"><img src="<?php echo plugins_url('/images/facebook.png', __FILE__); ?> "></a> <a href="http://www.twitter.com/intent/user?screen_name=cdsincdesign" target="_blank"><img src="<?php echo plugins_url('/images/twitter.png', __FILE__); ?> "></a> <a href="http://www.pinterest.com/hiphopsmurf" target="_blank"><img src="<?php echo plugins_url('/images/pinterest.png', __FILE__); ?> "></a> <!--a href="http://www.cdsincdesign.com/blog" target="_blank"><img src="<?php echo plugins_url('/images/wordpress.png', __FILE__); ?> "></a> <a href="http://www.cdsincdesign.com/feed" target="_blank"><img src="<?php echo plugins_url('/images/rss.png', __FILE__); ?> "></a> <a href="http://www.cdsincdesign.com/contact" target="_blank"><img src="<?php echo plugins_url('/images/email.png', __FILE__); ?> "></a--> </p> </div> </div> </div> <div class="meta-box-sortables"> <div id="about" class="postbox"> <h3 class="hndle" id="about-sidebar">Keep This Plugin Free!</h3> <div class="inside"> <p> <form method="POST" enctype="multipart/form-data" action="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=N56JT9B8VVAJN¤cy_code=USD&item_name=Plugin Donation - Thank You!" target="_blank"> <table border="0" cellpadding="5"> <tr> <td width="20%" align="center"><input type="radio" name="amount" value="5" checked><br>$5</td> <td width="20%" align="center"><input type="radio" name="amount" value="10"><br>$10</td> <td width="20%" align="center"><input type="radio" name="amount" value="25"><br>$25</td> <td width="20%" align="center"><input type="radio" name="amount" value="50"><br>$50</td> <td width="20%" align="center"><input type="radio" name="amount" value=""><br>Other<br></td> </tr></table> <input type="image" name="side-donate" value="Donate With PayPal!" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" /> </form> </p> <?php /*<hr /> <div style="font-size:16px;margin:0 auto;width:300px" class="blockchain-btn" data-address="13nmr9BCppELeLHwT3EnK4kwsHFYm8kJM2" data-shared="false" data-callback="<?php echo admin_url();?>"> <div class="blockchain stage-begin"> <img src="https://blockchain.info//Resources/buttons/donate_64.png"/> </div> <div class="blockchain stage-loading" style="text-align:center"> <img src="https://blockchain.info//Resources/loading-large.gif"/> </div> <div class="blockchain stage-ready"> <p align="center">Please Donate To Bitcoin Address: <b>[[address]]</b></p> <p align="center" class="qr-code"></p> </div> <div class="blockchain stage-paid"> Donation of <b>[[value]] BTC</b> Received. Thank You. </div> <div class="blockchain stage-error"> <font color="red">[[error]]</font> </div> </div>*/ ?> </div> </div> </div> <div class="meta-box-sortables"> <div id="about" class="postbox"> <h3 class="hndle" id="about-sidebar">Tell The World!</h3> <div class="inside"> <p><b>Like This Plugin? Please Share!</b></p> <p><table border="0" cellpadding="0" cellspacing="0"> <tr> <td style="padding-top:4px;"> <div class="fb-like" data-href="http://cdsincdesign.com/about/plugins/simple-dropbox-upload-form/" data-send="false" data-layout="button_count" data-show-faces="false"></div> </td> <td style="padding-top:4px;"> <a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.cdsincdesign.com/about/plugins/simple-dropbox-upload-form" data-text="Simple Dropbox Uploader for WordPress:" data-via="hipHOPsMuRf">Tweet</a> <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script> </td> <td id="gplus" style="padding-top:4px;"> <!-- Place this tag where you want the +1 button to render. --> <div class="g-plusone" data-size="medium" data-href="http://cdsincdesign.com/about/plugins/simple-dropbox-upload-form/"></div> <!-- Place this tag after the last +1 button tag. --> <script type="text/javascript"> (function() { var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = 'https://apis.google.com/js/plusone.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s); })(); </script> </td> <td id="pinterest" style="padding-top:4px;"> <a href="http://pinterest.com/pin/create/button/?url=http://www.cdsincdesign.com/about/plugins/simple-dropbox-upload-form&media=http://www.cdsincdesign.com/socialimg/simple-dropbox.png&description=WordPress%20plugin%20to%20allow%20users%20to%20upload%20files%20to%20specific%20folders%20on%20your%20Dropbox%20account%20using%20a%20simple%20shortcode%21" class="pin-it-button" count-layout="none"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a> <script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script> </td> </tr> </table></p> </div> </div> </div> <?php /* function renderWpsdbMetabox() { if (!function_exists('plugins_api')) { require_once(ABSPATH . '/wp-admin/includes/plugin-install.php'); } $api = plugins_api('plugin_information', array('slug' => 'wp-bug-tracker')); $status = install_plugin_install_status($api); if ($status['status'] == 'install') { $render = $status['url']; } else { $render = ''; } return $render; } $render = renderWpsdbMetabox(); if($render != ''): ?> <div class="meta-box-sortables"> <div id="about" class="postbox"> <h3 class="hndle" id="about-sidebar">Bug Tracker</h3> <div class="inside"> <div style="margin: 5px; float: left; width: 30px; padding: 10px 0 0 5px;"> <img title="logo" rel="logo" src="<?php echo plugins_url('/images/ahm.png',__FILE__);?>" /> </div> <div style="margin: 5px; float: left; width: 180px; text-align: justify;"> <a href="http://wordpress.org/extend/plugins/wp-bug-tracker/" target="_blank">Wordpress Bug Tracker</a><br /> will help us improve Simple Dropbox and you to maintain your system. </div> <div style="text-align: center"> <a href="<?php echo $render;?>" class="button button-primary button-large">Install Plugin</a> </div> <br class="clear" /> </div> </div> </div> <?php endif;*/ ?> </div><!-- END SIDE-INFO-COLUMN --> <!-- END SIDEBAR --> <!-- BEGIN CONTENT AREA --> <div id="post-body" class="has-sidebar"> <div id="post-body-content" class="has-sidebar-content"> <div id="normal-sortables" class="meta-box-sortables"> <div id="about" class="postbox"> <div class="inside"> <br class="clear" /> <!--center--> <?php if (get_option('wpsdb_auth_step') != 3) { ?> <p style="text-align:center"><a href="https://www.dropbox.com/referrals/NTIyNjI4MTM5OQ" target="_blank"><?php _e('Need a Dropbox account? Please use this link so we both get some extra space.', 'simpleDbUpload'); ?> </a></p><?php } ?> <?php $wpssure = rand(10000, 99999); ?> <p style="text-align:center;font-size:14px;color:#FF0000">Multiple File Upload has been disabled temporarily</p> <form name="wpsdb_form" method="POST" action=""> <input type="hidden" name="wpsdb_set_nonce" id="wpsdb_set_nonce" value="<?php echo wp_create_nonce(plugin_basename(__FILE__)); ?> "> <table class="form-table"> <tr> <th scope="row"><p><?php _e('Keep Simple Dropbox in settings menu.', 'simpleDbUpload'); ?> </p></th> <td> <input type="checkbox" name="wpsdb_menu_pref" value="settings_menu" <?php if (get_option('wpsdb_menu_pref') == 'settings_menu') { echo 'checked'; } ?> /> </td> </tr> <tr> <th scope="row"><p><?php _e('Path in dropbox folder.', 'simpleDbUpload'); ?> </p></th> <td><input type="text" size="60" name="wpsdb_path" value="<?php echo get_option('wpsdb_path'); ?> " /> <br /> <label class="wpsdb-label" for="inputid"><?php _e('All files/folders will be located in the base of your dropbox.', 'simpleDbUpload'); ?> </label></td> </tr> <tr> <th scope="row"><p><?php _e('Temporary path on server. Files get saved here if Dropbox server is down.', 'simpleDbUpload'); ?> </p></th> <td><input type="text" size="60" name="wpsdb_temp_path" value="<?php echo get_option('wpsdb_temp_path'); ?> " /> <br /> <label class="wpsdb-label" for="inputid"><strong><?php _e('Default Location:', 'simpleDbUpload'); ?> </strong> <?php echo ABSPATH . 'wp-content/uploads/wpdb'; ?> </label></td> </tr> <tr> <th scope="row"><p><?php _e('Allowed file extensions, separated by spaces.', 'simpleDbUpload'); ?> <strong>(<?php _e('Required', 'simpleDbUpload'); ?> )</strong></p></th> <td><input type="text" size="60" name="wpsdb_allow_ext" value="<?php echo get_option('wpsdb_allow_ext'); ?> " /> <br /> <label class="wpsdb-label" for="inputid"><strong><?php _e('Example:', 'simpleDbUpload'); ?> </strong> doc docx gif jpg jpeg pdf png psd tif tiff</label></td> </tr> <tr id="wpsdb-thank-message"> <th scope="row"><p><?php _e('Message displayed after uploading a file.', 'simpleDbUpload'); ?> <a href="javascript:void(0)" class="help"><img border="0" src="<?php echo plugins_url('/images/help.png', __FILE__); ?> "><span><strong>Single Upload:</strong> This will not be shown if progress indicators are enabled.<br /><strong>Multiple Upload:</strong> This will not be shown if a redirect page is set.</span></a></p></th> <td><input type="text" size="60" name="wpsdb_thank_message" value="<?php echo stripslashes(get_option('wpsdb_thank_message')); ?> " /></td> </tr> <tr id="wpsdb-thank-message-color"> <th scope="row"><p><?php _e('Text color of thank you message.', 'simpleDbUpload'); ?> </p></th> <td> <input type="text" name="wpsdb_thank_color" id="wpsdb-thank-color" value="<?php echo esc_attr(get_option('wpsdb_thank_color')); ?> " /> <a href="#" class="pickcolor hide-if-no-js" id="wpsdb-thank-color-example"></a> <input type="button" class="pickcolor button hide-if-no-js" value="<?php esc_attr_e('Select a Color', 'twentyeleven'); ?> " /> <div id="colorPickerDiv" style="z-index: 100; background:#eee; border:1px solid #ccc; position:absolute; display:none;"></div> <br /> <span><?php printf(__('Default color: %s', 'twentyeleven'), '<span id="default-color">#000000</span>'); ?> </span> </td> </tr> <tr> <th scope="row"><p><?php _e('Show upload progress indicators?(Experimental)', 'simpleDbUpload'); ?> <a href="javascript:void(0)" class="help"><img border="0" src="<?php echo plugins_url('/images/help.png', __FILE__); ?> "><span>This option will show a progress bar below the form to indicate how much of the file has been uploaded. It will also show a loading icon to help deter users from leaving the page before the file is uploaded.</span></a></p></th> <td><select name="wpsdb_show_progress" id="wpsdb_show_progress"> <option value="True" <?php if (get_option('wpsdb_show_progress') == "True") { ?> selected="selected"<?php } ?> ><?php _e('True', 'simpleDbUpload'); ?> </option> <option value="False" <?php if (get_option('wpsdb_show_progress') == "False") { ?> selected="selected"<?php } ?> ><?php _e('False', 'simpleDbUpload'); ?> </option> </select> </td> </tr> <tr id="redirect"> <th scope="row"><p><?php _e('Page directed to after uploading a file.', 'simpleDbUpload'); ?> <a href="javascript:void(0)" class="help"><img border="0" src="<?php echo plugins_url('/images/help.png', __FILE__); ?> "><span>Leave blank to have user directed back to upload form.</span></a></p></th> <td> <?php $wpsdb_page_option = get_option('wpsdb_redirect_page'); echo '<select name="wpsdb_redirect_page" style="width:150px"><option value="">'; $wpsdb_getpages = get_pages(); foreach ($wpsdb_getpages as $wpsdb_getpage) { if ($wpsdb_page_option == $wpsdb_getpage->ID) { $selected_redirect_page = 'selected="selected"'; } else { $selected_redirect_page = ''; } $option_redirect = '<option value="' . $wpsdb_getpage->ID . '" ' . $selected_redirect_page . '>'; $option_redirect .= $wpsdb_getpage->post_title; $option_redirect .= '</option>'; echo $option_redirect; } ?> </td> </tr> <?php /* <tr> <th scope="row"><p><?php _e('Show multiple upload link?<br />(Experimental)','simpleDbUpload');?> <a href="javascript:void(0)" class="help"><img border="0" src="<?php echo plugins_url( '/images/help.png', __FILE__ );?>"><span>Allows users to drag n drop multiple files.</span></a></p></th> <td><select name="wpsdb_show_multi" id="wpsdb_show_multi"> <option value="True" <?php if(get_option('wpsdb_show_multi')== "True"){?>selected="selected"<?php }?>><?php _e('True','simpleDbUpload');?></option> <option value="False" <?php if(get_option('wpsdb_show_multi')== "False"){?>selected="selected"<?php }?>><?php _e('False','simpleDbUpload');?></option> </select> </td> </tr> <tr id="multi_link_text"> <th scope="row"><p><?php _e('Multiple upload link text.','simpleDbUpload');?></p></th> <td><input type="text" size="60" name="wpsdb_multi_link_text" value="<?php echo stripslashes(get_option( 'wpsdb_multi_link_text' )); ?>" /></td> </tr> <tr id="multi_size"> <th scope="row"><p><?php _e('Per file size limit. (Multiple Upload Only)','simpleDbUpload');?></p></th> <td><select name="wpsdb_show_multi_size" id="wpsdb_show_multi_size"> <option value="1" <?php if(get_option('wpsdb_show_multi_size')== "1"){?>selected="selected"<?php }?>><?php _e('1MB','simpleDbUpload');?></option> <option value="5" <?php if(get_option('wpsdb_show_multi_size')== "5"){?>selected="selected"<?php }?>><?php _e('5MB','simpleDbUpload');?></option> <option value="10" <?php if(get_option('wpsdb_show_multi_size')== "10"){?>selected="selected"<?php }?>><?php _e('10MB','simpleDbUpload');?></option> <option value="15" <?php if(get_option('wpsdb_show_multi_size')== "15"){?>selected="selected"<?php }?>><?php _e('15MB','simpleDbUpload');?></option> <option value="20" <?php if(get_option('wpsdb_show_multi_size')== "20"){?>selected="selected"<?php }?>><?php _e('20MB','simpleDbUpload');?></option> </select> </td> </tr> */ ?> <tr id="showafter"> <th scope="row"><p><?php _e('Show upload form again after upload?', 'simpleDbUpload'); ?> <a href="javascript:void(0)" class="help"><img border="0" src="<?php echo plugins_url('/images/help.png', __FILE__); ?> "><span><strong>Single Upload:</strong> Doesn't apply to single uploads if progress indicators are enabled.<br /><strong>This feature will be removed in the future.</strong></span></a></p></th> <td><select name="wpsdb_show_form"> <option value="True" <?php if (get_option('wpsdb_show_form') == "True") { ?> selected="selected"<?php } ?> ><?php _e('True', 'simpleDbUpload'); ?> </option> <option value="False" <?php if (get_option('wpsdb_show_form') == "False") { ?> selected="selected"<?php } ?> ><?php _e('False', 'simpleDbUpload'); ?> </option> </select> </td> </tr> <tr> <th scope="row"><p><?php _e('Delete local file after upload to dropbox?', 'simpleDbUpload'); ?> </p></th> <td><select name="wpsdb_delete_file"> <option value="True" <?php if (get_option('wpsdb_delete_file') == "True") { ?> selected="selected"<?php } ?> ><?php _e('True', 'simpleDbUpload'); ?> </option> <option value="False" <?php if (get_option('wpsdb_delete_file') == "False") { ?> selected="selected"<?php } ?> ><?php _e('False', 'simpleDbUpload'); ?> </option> </select> </td> </tr> <tr> <th scope="row"><p><?php _e('Use CURL, PHP oAuth or PEAR oAuth?', 'simpleDbUpload'); ?> </p></th> <td><select name="wpsdb_php_pear"> <option value="curl" <?php if (get_option('wpsdb_php_pear') == "curl") { ?> selected="selected"<?php } ?> >Curl</option> <option value="php" <?php if (get_option('wpsdb_php_pear') == "php") { ?> selected="selected"<?php } ?> >PHP oAuth</option> <option value="pear" <?php if (get_option('wpsdb_php_pear') == "pear") { ?> selected="selected"<?php } ?> >PEAR oAuth</option> </select> </td> </tr> <tr> <th scope="row"><p><?php _e('RESET SETTINGS.', 'simpleDbUpload'); ?> </p></th> <td><input type="text" size="60" name="wpsdbreset" autocomplete="off" value="" /> <br /> <label class="wpsdb-label" for="inputid"><?php _e('PLEASE TYPE THE FOLLOWING NUMBERS: ', 'simpleDbUpload'); echo $wpssure; ?> </label></td> </tr> <tr> <th scope="row" style="width:300px;" class="last_item"> <input type="hidden" name="wpsdb_submit_hidden" value="Y" /> <input type="hidden" name="wpsdb_reset_confirm" value="<?php echo $wpssure; ?> " /> <input type="submit" class="button-primary" style="line-height:15px;" value="<?php _e('Save options', 'simpleDbUpload'); ?> " /><?php $buttonShow = get_option('wpsdb_auth_step'); if ($buttonShow == "0" || $buttonShow == "1") { ?> <a class="thickbox button-secondary" <?php if (get_option('wpsdb_auth_step') == 0) { echo 'disabled="disabled"'; } ?> href="<?php echo get_option('siteurl'); ?> /wp-admin/admin-ajax.php?action=choice&width=450&height=350" title="Authorize"><?php _e('Authorize', 'simpleDbUpload'); ?> </a> <?php } if ($buttonShow == "2") { ?> <a class="thickbox button-secondary" href="<?php echo get_option('siteurl'); ?> /wp-admin/admin-ajax.php?action=choice&width=450&height=350" title="Confirm"><?php _e('Confirm', 'simpleDbUpload'); ?> </a> <?php } ?> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=K6XUBZSU8RWR2" target="_blank"><img style="margin-bottom:-7px;height:23px;" src="https://www.paypal.com/en_US/i/btn/btn_donate_LG.gif" alt="" /></a> </th> <td class="last_item"></td> </tr> </table> </form> <script> jQuery(document).ready( function($) { var h = jQuery.noConflict(); h("#wpsdb_show_progress").change(function(){ progress_switch(); }); progress_switch = function(){ if(h("#wpsdb_show_progress").val() == "True"){ //h("#wpsdb-thank-message,#wpsdb-thank-message-color,#showafter").hide(); h("#redirect").show(); }else{ //h("#wpsdb-thank-message,#wpsdb-thank-message-color,#showafter").show(); h("#redirect").hide(); } } progress_switch(); h("#wpsdb_show_multi").change(function(){ multiple_switch(); }); multiple_switch = function(){ if(h("#wpsdb_show_multi").val() == "True"){ h("#multi_size,#multi_link_text").show(); }else{ h("#multi_size,#multi_link_text").hide(); } } multiple_switch(); }) </script> <!--/center--> <br class="clear" /> </div><!-- END INSIDE --> </div><!-- END ABOUT --> </div><!-- END NORMAL-SORTABLES --> </div><!-- END POST-BODY-CONTENT--> </div><!-- END POST-BODY --> </div><!-- END POSTSTUFF --> </div><!-- END WRAP --> <?php $check_settings = new wpsdbFunction(); //$check_settings->removeSettingsGroup(); /*$whattokeep = array('wpsdb_version_number','wpsdb_menu_pref','wpsdb_delete_file',NULL); $check_settings->updateSettingsGroup($whattokeep);*/ }
static function tryToConnect($call_back_link, $user_id, $token = null) { if (isset($token)) { //token übergeben $_SESSION['oauth_tokens'] = array("token" => $token['token'], "token_secret" => $token['token_secret']); $_SESSION['state'] = 3; $state = 3; } if (!isset($_SESSION['state'])) { //ganz neu $_SESSION['state'] = 1; } $state = $_SESSION['state']; //try to login $consumerKey = '5wty9mf06gcuco0'; $consumerSecret = 'hveok3hllw48hji'; $oauth = new \Dropbox_OAuth_PEAR($consumerKey, $consumerSecret); $dropbox = new \Dropbox_API($oauth, \Dropbox_API::ROOT_SANDBOX); try { switch ($state) { /* In this phase we grab the initial request tokens and redirect the user to the 'authorize' page hosted on dropbox */ case 1: $tokens = $oauth->getRequestToken(); $link = $oauth->getAuthorizeUrl($call_back_link) . "\n"; // Note that if you want the user to automatically redirect back, you can // add the 'callback' argument to getAuthorizeUrl. $link = $oauth->getAuthorizeUrl($call_back_link) . "\n"; $_SESSION['state'] = 2; $_SESSION['oauth_tokens'] = $tokens; return $link; break; /* In this phase, the user just came back from authorizing and we're going to fetch the real access tokens */ /* In this phase, the user just came back from authorizing and we're going to fetch the real access tokens */ case 2: $oauth->setToken($_SESSION['oauth_tokens']); try { $tokens = $oauth->getAccessToken(); $_SESSION['state'] = 3; $state = 3; $_SESSION['oauth_tokens'] = $tokens; } catch (\PEAR_Exception $e) { $_SESSION['state'] = 1; $state = 1; $_SESSION['oauth_tokens'] = NULL; $tokens = NULL; $link = $oauth->getAuthorizeUrl($call_back_link) . "\n"; return self::tryToConnect($call_back_link, $user_id); break; } // There is no break here, intentional /* This part gets called if the authentication process already succeeded. We can use our stored tokens and the api should work. Store these tokens somewhere, like a database */ // There is no break here, intentional /* This part gets called if the authentication process already succeeded. We can use our stored tokens and the api should work. Store these tokens somewhere, like a database */ case 3: try { $oauth->setToken($_SESSION['oauth_tokens']); //checks if Connection is Good $dropbox->getAccountInfo(); } catch (\Dropbox_Exception $e) { $_SESSION['state'] = 1; $state = 1; $link = $oauth->getAuthorizeUrl($call_back_link) . "\n"; unset($_SESSION['oauth_tokens']); // delete the stored token self::deleteToken($user_id); return self::tryToConnect($call_back_link, $user_id); } catch (\HTTP_OAuth_Exception $e) { $_SESSION['state'] = 1; $state = 1; $link = $oauth->getAuthorizeUrl($call_back_link) . "\n"; unset($_SESSION['oauth_tokens']); // delete the stored token self::deleteToken($user_id); return self::tryToConnect($call_back_link, $user_id); } break; } //connection should be good self::storeToken($user_id); return "connected"; } catch (Exception $e) { return false; } catch (\HTTP_OAuth_Exception $e) { return false; } catch (\Dropbox_Exception $e) { return false; } }
function choice() { /* Please supply your own consumer key and consumer secret */ $consumerKey = get_option('wpsdb_key'); $consumerSecret = get_option('wpsdb_secret'); include 'Dropbox/autoload.php'; $oauth = new Dropbox_OAuth_Wordpress($consumerKey, $consumerSecret); /****************TODO************* / if(get_option('wpsdb_php_pear')=="php"){ include 'Dropbox/autoload.php'; $oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret); if (!class_exists('OAuth')){ // We're going to tell you echo "PHP OAuth was not found on this server"; echo '<br /><button class="button" style="line-height:15px;margin-left:5px;" onClick="parent.tb_remove();">Close</button> '; exit(); } } // If the PHP OAuth extension is not available, you can try // PEAR's HTTP_OAUTH instead. if(get_option('wpsdb_php_pear')=="pear"){ include 'Dropbox/autoload.php'; $oauth = new Dropbox_OAuth_PEAR($consumerKey, $consumerSecret); if (!class_exists('HTTP_OAuth_Consumer')) { // We're going to tell you print "HTTP OAuth is not installed on this server."; print '<br /><button class="button" style="line-height:15px;margin-left:5px;" onClick="parent.tb_remove();">Close</button> '; exit(); } } /***********************************/ $state = get_option('wpsdb_auth_step'); if ($state == "1" || $state == "") { $state = 1; } switch ($state) { default: echo "Please confirm the requred fields are populated."; echo '<br /><button class="button" style="line-height:15px;margin-left:5px;" onClick="parent.tb_remove();">Close</button> '; die; case 1: echo "<strong>Step 1:</strong> Pre-authorization acquired!<br />"; $tokens = $oauth->getRequestToken(); update_option('wpsdb_auth_step', 2); update_option('wpsdb_auth_token', $tokens['token']); update_option('wpsdb_auth_token_secret', $tokens['token_secret']); //print_r($tokens); // Note that if you want the user to automatically redirect back, you can // add the 'callback' argument to getAuthorizeUrl. echo "<strong>Step 2:</strong> After pressing continue you will be redirected to DropBox.<br />\r\n\r\n\t\t\t After accepting the authorization you will be redirected back to the<br />WordPress Admin. Return\r\n\r\n\t\t\t to the plugin settings page and press the Confirm button to finish the process."; //echo '<a href="'.$oauth->getAuthorizeUrl().'" class="button" target="_blank">GO!</a>'; echo '<br /><br /><a href="' . $oauth->getAuthorizeUrl(get_option('siteurl') . '/wp-admin/') . '" class="button-primary">Continue</a>'; echo '<button class="button" style="line-height:15px;margin-left:5px;" onClick="parent.displaymessage();">Cancel</button> '; die; case 2: echo "<strong>Step 3:</strong> Confirming authorization... "; $wpsdb_token = get_option('wpsdb_auth_token'); $wpsdb_token_secret = get_option('wpsdb_auth_token_secret'); $oauth->setToken($wpsdb_token, $wpsdb_token_secret); try { $tokens = $oauth->getAccessToken(); } catch (Dropbox_Exception_RequestToken $r) { echo "<br /><strong>It seems your authorization might be expired or invalid."; echo "<br />This might be resolved by using the reset settings feature in the"; echo "<br />settings panel or alternately disabling the plugin and re-enabling it</strong>"; print '<br /><br /><button class="button-primary" style="line-height:15px;margin-left:5px;" onClick="parent.tb_remove();">Close</button> '; break; } //print_r($tokens); update_option('wpsdb_auth_step', 3); update_option('wpsdb_auth_token', $tokens['token']); update_option('wpsdb_auth_token_secret', $tokens['token_secret']); echo "DONE |<br />"; case 3: //echo "The user is authenticated\n"; $wpsdb_token = get_option('wpsdb_auth_token'); $wpsdb_token_secret = get_option('wpsdb_auth_token_secret'); $oauth->setToken($wpsdb_token, $wpsdb_token_secret); echo "<strong>Account info:</strong> "; $wpsdropbox = new Dropbox_API($oauth); $wpsdropbox_ainfo = $wpsdropbox->getAccountInfo(); echo $wpsdropbox_ainfo['email']; if (get_option('wpsdb_menu_pref') != 'main') { echo '<br /><br /><a href="' . get_option('siteurl') . '/wp-admin/options-general.php?page=simple-dropbox-upload-form/wp-dropbox.php" class="button-primary">Finish!</a><br /><br />'; } else { echo '<br /><br /><a href="' . get_option('siteurl') . '/wp-admin/admin.php?page=simple-dropbox-upload-form/wp-dropbox.php" class="button-primary">Finish!</a><br /><br />'; } break; } /*$wpsdropbox = new Dropbox_API($oauth); //echo "<strong>Account info:</strong> "; $wpsdropbox_ainfo = $wpsdropbox->getAccountInfo(); echo $wpsdropbox_ainfo['email'];*/ //echo '<br /><br /><a href="'.get_option('siteurl').'/wp-admin/options-general.php?page=simple-dropbox-upload-form/wp-dropbox.php" class="button">Finish!</a><br /><br />'; //print_r($dropbox->getAccountInfo()); exit; }
$oauth = new Dropbox_OAuth_PEAR($config['dropbox_token'], $config['dropbox_seckey']); } catch (Exception $e) { $state = 0; } } } if (!empty($config['dropbox_acc_token']) && !empty($config['dropbox_acc_seckey'])) { $_SESSION[$state_key . '_tokens'] = array('token' => $config['dropbox_acc_token'], 'token_secret' => $config['dropbox_acc_seckey']); $state = 3; } if ($state > 2 && isset($_SESSION[$state_key . '_tokens'])) { // acc token check try { $oauth->setToken($_SESSION[$state_key . '_tokens']); $dropbox = new Dropbox_API($oauth); $dropbox->getAccountInfo(); } catch (Dropbox_Exception $e) { unset($_SESSION[$state_key], $_SESSION[$state_key . '_tokens']); $state = 0; } } } if ($state) { $dropbox = new Dropbox_API($oauth); switch ($state) { case 1: $tokens = array(); if (!($url = xelfinderAdminDropboxGetAuthorizeUrl($tokens, $oauth, $mydirname))) { $state = 0; } break;