Exemplo n.º 1
0
 public function stream_close()
 {
     $res = fclose(self::$crtHandle);
     if (self::$crtWritePath != null) {
         $path = $this->initPath(self::$crtWritePath);
         try {
             $postRes = self::$dropbox->putFile($path, self::$crtTmpFile);
             AJXP_Logger::debug(__CLASS__, __FUNCTION__, "Post to {$path} succeeded:");
         } catch (Dropbox_Exception $dE) {
             AJXP_Logger::debug(__CLASS__, __FUNCTION__, "Post to {$path} failed :" . $dE->getMessage());
         }
     }
     unlink(self::$crtTmpFile);
     return $res;
 }
Exemplo n.º 2
0
	    </li>
    </ul>
    <a href="<?=$dropCom ?>" data-role="button" data-theme="b">StudIp verbinden</a>
	<?
}
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> 
Exemplo n.º 3
0
require_once 'Dropbox.php';



$consumerKey = '4345435636dffr2455';
$consumerSecret = '442342342343254asa';




session_start();


$oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret);

$dropbox = new Dropbox_API($oauth);

$account = $dropbox->getAccountInfo();

echo $account;


$tokens = $dropbox->getToken('*****@*****.**', 'wowpassword');

$_SESSION["oauth_tokens"]=$tokens;

$oauth->setToken($oauth_tokens);

$metaData = $dropbox->metaData();

if ($file_type = $data->mime_type !="jpeg/image") {
Exemplo n.º 4
0
 /**
  * @param \Dropbox_API $dropbox
  */
 function it_fails_checking_if_key_is_dir_when_dropbox_throws_exception($dropbox)
 {
     $dropbox->getMetaData('filename', false)->willThrow(new \RuntimeException('some exception'));
     $this->shouldThrow(new \RuntimeException('some exception'))->duringIsDirectory('filename');
 }
Exemplo n.º 5
0
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>&nbsp;
                    <a href="http://www.twitter.com/intent/user?screen_name=cdsincdesign" target="_blank"><img src="<?php 
    echo plugins_url('/images/twitter.png', __FILE__);
    ?>
"></a>&nbsp;
                    <a href="http://www.pinterest.com/hiphopsmurf" target="_blank"><img src="<?php 
    echo plugins_url('/images/pinterest.png', __FILE__);
    ?>
"></a>&nbsp;
                    <!--a href="http://www.cdsincdesign.com/blog" target="_blank"><img src="<?php 
    echo plugins_url('/images/wordpress.png', __FILE__);
    ?>
"></a>&nbsp;
                    <a href="http://www.cdsincdesign.com/feed" target="_blank"><img src="<?php 
    echo plugins_url('/images/rss.png', __FILE__);
    ?>
"></a>&nbsp;
                    <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&currency_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);*/
}
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 7
0
<?php

$consumerKey = 'key';
// key
$consumerSecret = 'sercret';
// sercret
include 'vendor/dropbox-php/dropbox-php/src/Dropbox/autoload.php';
$oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret);
$dropbox = new Dropbox_API($oauth);
// auth
$tokens = $dropbox->getToken('email', 'pass');
$oauth->setToken($tokens);
$h = fopen('/PATH/browserling.jpg', 'r');
// upload file
$dropbox->putFile('browserling.jpg', $h);
// put file
  protected function doProcess($arguments = array(), $options = array())
  {

    # DISABLED
    //$this->logBlock('DISABLED.', 'ERROR');
    // exit;
    
    
    
    

    if (!$options['go']) 
      $this->logBlock('Running in dry mode, no files will be uploaded.', 'ERROR');

    $consumerKey = sfConfig::get("app_dropbox_consumer_key");
    $consumerSecret = sfConfig::get("app_dropbox_consumer_secret");
    $token = sfConfig::get("app_dropbox_token");
    $token_secret = sfConfig::get("app_dropbox_token_secret");
    $dropboxRoot = sfConfig::get("app_dropbox_root");
    
    ProjectConfiguration::registerDropboxAPI();
    
    // If the PHP OAuth extension is not available, you can try
    // PEAR's HTTP_OAUTH instead.
    $oauth = new Dropbox_OAuth_PEAR($consumerKey, $consumerSecret);
    $dropbox = new Dropbox_API( $oauth );
    $tokens = array(
                "token"        => $token,
                "token_secret" => $token_secret
              );
    $oauth->setToken($tokens);


    // get DROPBOX directory listing
    $metadata = $dropbox->getMetaData($dropboxRoot, $list = true, $hash = null, $fileLimit = null, $root = null);
    $dropbox_list = array();
    
    $this->logBlock(sprintf("Connected dropbox in %s", $dropboxRoot), 'COMMENT');
    
    if (is_array( $metadata['contents'] )) {
      foreach( $metadata['contents'] as $info)
      {
                
        /*
        if ($info["mime_type"] == "application/pdf") {
          $filename = strtolower( basename( $info["path"] ) );
          */
          
          $filename = strtolower( basename( $info["path"] ) );

          // https://www.dropbox.com/developers/docs
          $timestamp = strtotime($info["modified"]);
          
          /*
          $ftime = strptime($info["modified"], "%a, %d %b %Y %H:%M:%S %z");
          $timestamp = mktime( 
                    $ftime['tm_hour'], 
                    $ftime['tm_min'], 
                    $ftime['tm_sec'], 
                    1 , 
                    $ftime['tm_yday'] + 1, 
                   $ftime['tm_year'] + 1900 
                 );
          */
         
          // time zone problem ?!?
          //$timestamp = strtotime("+2 hours", $timestamp);
          
          $dropbox_list["$filename"] = $timestamp;
        // }
      }
    }
    
    // compare DROPBOX contents to "live" files
    $push_files = array();
    $dir = sfConfig::get('sf_data_dir').sfConfig::get('app_rockstep_pdf_dir');
    $weeds = array('.', '..','.DS_Store'); 
    $directory = array_diff(scandir($dir), $weeds); 

    if (!$options['force']) {
      $this->logBlock(sprintf("Checking %d files in %s", count($directory), $dir), 'COMMENT');
    } else {
      $this->logBlock(sprintf("Pushing %d files from %s", count($directory), $dir), 'COMMENT');
    }
    
    foreach( $directory as $id => $filename ) {
      if (is_file($dir.$filename)) {
        if (!$options['force']) {
          if (array_key_exists(strtolower($filename), $dropbox_list)) {

            $this->logSection('file', sprintf("%s %s %s", $filename, filemtime($dir.$filename), $dropbox_list[strtolower($filename)] ));

            //echo date('Y-m-d H:m:s u', strtotime( $dropbox_list[strtolower($filename)] ))."--".date('Y-m-d H:m:s u', filemtime($dir.$filename));

            if ( filemtime($dir.$filename) > $dropbox_list[strtolower($filename)] ) {

              //echo date('Y-m-d H:m:s', $dropbox_list[strtolower($filename)] )."--".date('Y-m-d H:m:s', filemtime($dir.$filename));

              $push_files[] = $filename;
            }
          } else {
            $push_files[] = $filename;
          }
        } else {
          $push_files[] = $filename;
        }
      }
    }
    
    // PUSH to dropbox
    $error = 0; $success = 0;
    if (count($push_files) == 0) {
        $this->logBlock("Everything is up to date.", 'INFO');
        $this->task->setErrorCode(304);
        $this->setOk();
    } else {
      if (!$options['force'])
        $this->logBlock(sprintf("%d files have been modified", count($push_files)), 'INFO');
      foreach ($push_files as $filename) {
        if ($options['go']) {
         // sync
         
          $this->logBlock(sprintf("try: %s => %s", $dir.$filename, $dropboxRoot.$filename), 'INFO');
         $result = $dropbox->putFile($dropboxRoot.$filename, $dir.$filename);
                  
         if($result['httpStatus'] == 200 ) {
         
            // set datemodified to the dropbox-date
            $metadata = $dropbox->getMetaData($dropboxRoot.$filename, $list = true, $hash = null, $fileLimit = null, $root = null);
            touch($dir.$filename, strtotime($metadata['modified']) );

            //echo date('Y-m-d H:m:s u', strtotime($metadata['modified']))."--".date('Y-m-d H:m:s u', filemtime($dir.$filename));
            //echo strtotime($metadata['modified']);
            
            $this->logSection('file+', sprintf("%s", $filename));
            $success += 1;
            
          } else {
            $this->logSection('error', sprintf("%s", $filename));
            $error += 1;
          }
        
        } else {
          // dry run
          $this->logSection('file+', sprintf("%s", $filename));
          $success += 1;
        }
      }
      
      if ($options['go']) {
        if ($error > 0) {
          $this->logBlock(sprintf('Error Uploading on %d out of %d Files', $error, $success, $dropboxRoot), 'ERROR');
          $this->task->setErrorCode(500);
          $this->setNOk($error);
        } else {
          $this->logBlock(sprintf('Uploaded %d Files to %s', $success, $dropboxRoot), 'INFO');
          $this->task->setErrorCode(200);
          $this->setOk();
        }
      } else {
        // dry run
      } 
    }
    
  }
Exemplo n.º 9
0
 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;
     }
 }
Exemplo n.º 10
0
<?php

if (isset($_POST['allow_access'])) {
    //modify include path to work w/ PEAR on Dreamhost
    ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . "/home/kshrine/.pear/home/kshrine/pear/php");
    $consumerKey = '';
    $consumerSecret = '';
    include 'Dropbox/autoload.php';
    $oauth = new Dropbox_OAuth_PEAR($consumerKey, $consumerSecret);
    $dropbox = new Dropbox_API($oauth);
    $tokens = $dropbox->getToken($_POST['email_address'], $_POST['password']);
    update_option('wpdp_token', $tokens);
    $stored_tokens = get_option('wpdp_token');
    $oauth->setToken($stored_tokens);
    $acct_info = $dropbox->getAccountInfo();
    update_option('wpdp_acct_name', $acct_info['display_name']);
}
?>
<div class="wrap">
  <h2>WP-Dropbox</h2>
  <?php 
$name_on_authorized_acct = get_option('wpdp_acct_name');
if (empty($name_on_authorized_acct)) {
    echo "<h3>No Dropbox in use.</h3>";
} else {
    echo "<h3>Using {$name_on_authorized_acct}'s Dropbox.</h3>";
}
?>


Exemplo n.º 11
0
            try {
                $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;
            }
Exemplo n.º 12
0
 static function DropboxUpload($fileid)
 {
     /*
      * This script shoud upload a file to a 
      * special folder in the users dropbox.
      * The session should bestarted and the
      * user should be logged in already.
      *
      * @author Nils Bussmann <*****@*****.**>
      * @date   05.02.2011
      * @param  filename should be the path to the local file 
      * @param  folder the folder in the dropbox
      *
      * @return  fail:   filename    if something went wrong
      *          success:filename    if everything went right
      *          exists: filename    if the file already exists
      */
     if (isset($fileid)) {
         session_start();
         //generate filename, filepath, intended_path
         //get filename from database
         $db = \DBManager::get();
         $query = "   SELECT dokument_id, range_id, filename, seminar_id\n\t\t\t\t\t\tFROM    dokumente\n\t\t\t\t\t\tWHERE   dokumente.dokument_id =  '{$fileid}' ";
         $file_result = $db->query($query)->fetchAll();
         //get folder from database
         $seminar_id = $file_result[0]["seminar_id"];
         $range_id = $file_result[0]["range_id"];
         $query = "   SELECT  folder.folder_id, folder.name as folder_name, seminare.Seminar_id, seminare.name as seminar_name\n\t\t\t\t\t\tFROM    folder\n\t\t\t\t\t\tJOIN    seminare ON seminare.Seminar_id  =  '{$seminar_id}' \n\t\t\t\t\t\tWHERE   folder.folder_id =  '{$range_id}' ";
         $folder_result = $db->query($query)->fetchAll();
         // repart the important strings
         $filename = \Helper::cleanFilename($file_result[0]["filename"]);
         $file = $GLOBALS['UPLOAD_PATH'] . "/" . substr($fileid, 0, 2) . "/" . $fileid;
         $folder = \Helper::cleanFilename($folder_result[0]["seminar_name"] . "/" . $folder_result[0]["folder_name"]);
         //check if everthing is allright
         if (!isset($filename) || !isset($file) || !isset($folder)) {
             if (!isset($filename)) {
                 $filename = fileid;
             }
             return "fail:" . $filename;
         }
         /* start interaction width dropbox
            session shoud be started, user should logged in
            Please supply your own consumer key and consumer secret */
         $consumerKey = '5wty9mf06gcuco0';
         $consumerSecret = 'hveok3hllw48hji';
         try {
             $oauth = new \Dropbox_OAuth_PEAR($consumerKey, $consumerSecret);
             $dropbox = new \Dropbox_API($oauth, \Dropbox_API::ROOT_SANDBOX);
             $oauth->setToken($_SESSION['oauth_tokens']);
             //Check if the directories are created and
             //single subfolders in $folders
             $folders = explode("/", $folder);
             $checked_path = "/";
             foreach ($folders as $subfolder) {
                 $found_folder = false;
                 $info = $dropbox->getMetaData($checked_path);
                 foreach ($info["contents"] as $meta_info) {
                     if ($meta_info["is_dir"] == 1 && \Helper::endsWith($meta_info["path"], $subfolder)) {
                         $found_folder = true;
                         break;
                     }
                 }
                 if (!$found_folder) {
                     $dropbox->createFolder($checked_path . "/" . $subfolder);
                 }
                 if ($checked_path == "/") {
                     $checked_path .= $subfolder;
                 } else {
                     $checked_path .= "/" . $subfolder;
                 }
             }
             //depending folder exists
             //check if file already exisits
             $found = false;
             // $found shows if file already exisits
             $info = $dropbox->getMetaData($folder);
             foreach ($info["contents"] as $array_files) {
                 if (strpos($array_files["path"], $filename) != false) {
                     $ausgabe = "exists:" . $filename;
                     $found = true;
                 }
             }
             //Upload the file if nessasery
             if ($found == false) {
                 if ($dropbox->putFile($folder . "/" . $filename, $file)) {
                     $ausgabe = "success:" . $filename;
                 } else {
                     $ausgabe = "fail:" . $filename;
                 }
             }
         } catch (Exception $e) {
             // something went wrong, not specified
             // to specify the error there are other exeptions to catch
             $ausgabe = "fail:" . $filename;
         } catch (HTTP_OAuth_Exception $e) {
             $ausgabe = "fail:" . $filename;
         }
     } else {
         $ausgabe = "fail:" . $filename;
     }
     return $ausgabe;
 }
Exemplo n.º 13
0
 /**
  * Returns a file's contents
  *
  * @param string $path path
  * @param string $root Use this to override the default root path (sandbox/dropbox)
  * @return string
  */
 public function getFile($path = '', $root = null)
 {
     return $this->dropbox->getFile($path, $root);
 }
// I used Dropbox PHP client library from : http://code.google.com/p/dropbox-php/
// and for Authentication to work...
// i have installed OAuth php extension on the Apache2 server (Debian 6.0)
// using "pecl install oauth" command. and restarted the Apache2 server.
/* Please supply your own consumer key and consumer secret */
// you can get one after you register with Dropbox developer community
// https://www.dropbox.com/developers
$consumerKey = 'iurx6cwhtzgynve';
$consumerSecret = 'k50pkbah4b6jt73';
include 'Dropbox/autoload.php';
//session_start();
$oauth = new Dropbox_OAuth_PHP($consumerKey, $consumerSecret);
// If the PHP OAuth extension is not available, you can try
// PEAR's HTTP_OAUTH instead.
// $oauth = new Dropbox_OAuth_PEAR($consumerKey, $consumerSecret);
$dropbox = new Dropbox_API($oauth);
//header('Content-Type: text/plain');
// Did we get user email and password from a previous Dialog post?
// if not, let's try to get it from Cookies
if (empty($useremail)) {
    $useremail = $_COOKIE['dropbox_useremail'];
}
if (empty($userpassword)) {
    $userpassword = $_COOKIE['dropbox_userpassword'];
}
// If no POST and no COOKIE...
if (empty($useremail) or empty($userpassword)) {
    print_header_simple();
    echo "<div style='direction:ltr; text-align:center;'>";
    echo "<form id=\"dropboxuser\" method=\"post\" action=\"dialog.php\">";
    echo get_string('whatisuseremail', 'dropbox', '', $CFG->dirroot . '/lib/editor/htmlarea/custom_plugins/dropbox/lang/') . '<br/><input type="text" name="useremail" id="useremail"><br/>';