当前位置: 首页>>代码示例>>PHP>>正文


PHP dropbox::downloadFile方法代码示例

本文整理汇总了PHP中dropbox::downloadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP dropbox::downloadFile方法的具体用法?PHP dropbox::downloadFile怎么用?PHP dropbox::downloadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dropbox的用法示例。


在下文中一共展示了dropbox::downloadFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: wpadm_restore_dropbox

 public static function wpadm_restore_dropbox()
 {
     require_once DRBBACKUP_BASE_DIR . "/modules/class-wpadm-core.php";
     @session_write_close();
     $log_class = new WPAdm_Core(array('method' => "local"), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
     if (file_exists(WPAdm_Core::getTmpDir() . "/logs2")) {
         @unlink(WPAdm_Core::getTmpDir() . "/logs2");
     }
     if (file_exists(WPAdm_Core::getTmpDir() . "/log.log")) {
         @unlink(WPAdm_Core::getTmpDir() . "/log.log");
     }
     WPAdm_Core::log(langWPADM::get('Start Restore from Dropbox cloud', false));
     $dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
     if ($dropbox_options) {
         require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
         $dropbox_options = unserialize(base64_decode($dropbox_options));
         $folder_project = self::getNameProject();
         $dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
         if ($dropbox->isAuth()) {
             WPAdm_Core::mkdir(DROPBOX_BACKUP_DIR_BACKUP);
             $name_backup = isset($_POST['name']) ? trim($_POST['name']) : "";
             $dir_backup = DROPBOX_BACKUP_DIR_BACKUP . "/{$name_backup}";
             $error = WPAdm_Core::mkdir($dir_backup);
             if (!empty($error)) {
                 WPAdm_Core::log($error);
                 $res['result'] = WPAdm_Result::WPADM_RESULT_ERROR;
                 $res['error'] = $error;
                 $res['data'] = array();
                 $res['size'] = 0;
             } else {
                 $files = $dropbox->listing("{$folder_project}/{$name_backup}");
                 if (isset($files['items'])) {
                     $n = count($files['items']);
                     for ($i = 0; $i < $n; $i++) {
                         $res = $dropbox->downloadFile("{$folder_project}/{$name_backup}/{$files['items'][$i]['name']}", "{$dir_backup}/{$files['items'][$i]['name']}");
                         if ($res != "{$dir_backup}/{$files['items'][$i]['name']}" && isset($res['text'])) {
                             WPAdm_Core::log(langWPADM::get('Error: ', false) . $res['text']);
                         } else {
                             $log = str_replace('%s', $files['items'][$i]['name'], langWPADM::get('Download file (%s) with Dropbox', false));
                             WPAdm_Core::log($log);
                         }
                     }
                     parent::$type = 'full';
                     $backup = new WPAdm_Core(array('method' => "local_restore", 'params' => array('types' => array('files', 'db'), 'name_backup' => $name_backup)), 'full_backup_dropbox', WPAdm_Core::$pl_dir);
                     $res = $backup->getResult()->toArray();
                     WPAdm_Core::rmdir($dir_backup);
                 }
             }
         } else {
             WPAdm_Core::log(langWPADM::get('Website "%d" can\'t authorize on Dropbox with using of "app key: %k" and "app secret: %s"', false, array('%d', '%k', '%s'), array(SITE_HOME, $dropbox_options['app_key'], $dropbox_options['app_secret'])));
         }
     } else {
         WPAdm_Core::log(langWPADM::get('Website "%d" returned an error during connection to Dropbox: "app key" and "app secret" wasn\'t found. Please, check your Dropbox settings.', false, '%d', SITE_HOME));
     }
     @session_start();
     echo json_encode($res);
     wp_die();
 }
开发者ID:derwegas,项目名称:strubbelkinder,代码行数:58,代码来源:wpadm-class-wp.php


注:本文中的dropbox::downloadFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。