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


PHP dropbox::isAuth方法代码示例

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


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

示例1: execute

 public function execute(WPAdm_Command_Context $context)
 {
     @session_start();
     require_once WPAdm_Core::getPluginDir() . '/modules/dropbox.class.php';
     WPAdm_Core::log(langWPADM::get('Send to dropbox files', false));
     $dropbox = new dropbox($context->get('key'), $context->get('secret'), $context->get('token'));
     if (!$dropbox->isAuth()) {
         $context->setError(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, $context->get('key'), $context->get('secret'))));
         return false;
     }
     $files = $context->get('files');
     $file = explode("/", $files);
     $file_name = array_pop($file);
     $folder_project_temp = $context->get('folder_project');
     $folder_project = "";
     if (!empty($folder_project_temp)) {
         $folder_project = $folder_project_temp . "/";
         $dropbox->createDir($folder_project_temp);
         $dropbox->createDir($folder_project . $context->get('folder'));
     } else {
         $dropbox->createDir($context->get('folder'));
     }
     $fromFile = str_replace('//', '/', $files);
     $toFile = str_replace('//', '/', $folder_project . $context->get('folder') . '/' . $file_name);
     $res = $dropbox->uploadFile($fromFile, $toFile);
     if (isset($res['error']) && isset($res['text']) && $res['error'] == 1) {
         $context->setError(langWPADM::get('Dropbox returned an error during file sending: ', false) . '"' . $res['text'] . '"');
         return false;
     }
     if (isset($res['size']) && isset($res['client_mtime'])) {
         WPAdm_Core::log(langWPADM::get('File upload: ', false) . basename($files) . langWPADM::get(' size: ', false) . $res['size']);
     }
     return true;
 }
开发者ID:NYC2015,项目名称:team-12,代码行数:34,代码来源:class-wpadm-command-send-to-dropbox.php

示例2: 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

示例3: execute

 public function execute(WPAdm_Command_Context $context)
 {
     @session_start();
     require_once WPAdm_Core::getPluginDir() . '/modules/dropbox.class.php';
     WPAdm_Core::log(langWPADM::get('Send to dropbox files', false));
     $dropbox = new dropbox($context->get('key'), $context->get('secret'), $context->get('token'));
     if (!$dropbox->isAuth()) {
         $context->setError(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, $context->get('key'), $context->get('secret'))));
         return false;
     }
     $files = $context->get('files');
     $file = explode("/", $files);
     $file_name = array_pop($file);
     $folder_project_temp = $context->get('folder_project');
     $folder_project = "";
     if (!empty($folder_project_temp)) {
         $folder_project = $folder_project_temp . "/";
         $dropbox->createDir($folder_project_temp);
         $dropbox->createDir($folder_project . $context->get('folder'));
     } else {
         $dropbox->createDir($context->get('folder'));
     }
     $fromFile = str_replace('//', '/', $files);
     $toFile = str_replace('//', '/', $folder_project . $context->get('folder') . '/' . $file_name);
     $local = $context->get('local');
     $file_dropbox = $dropbox->listing($folder_project . $context->get('folder') . '/' . $file_name);
     $send = true;
     if (!isset($file_dropbox['error'])) {
         if ($file_dropbox['bytes'] != filesize($fromFile)) {
             $delete_file = $dropbox->deleteFile($folder_project . $context->get('folder') . '/' . $file_name);
             if (isset($delete_file['error'])) {
                 $context->setError(langWPADM::get('Dropbox returned an error during file sending: ', false) . '"' . $delete_file['text'] . '"');
                 return false;
             }
             $data_error_command = WPAdm_Running::getCommandResultData('errors_sending');
             if (isset($data_command[$fromFile])) {
                 $data_error_command[$fromFile]['count'] += 1;
             } else {
                 $data_error_command[$fromFile] = array();
                 $data_error_command[$fromFile]['count'] = 1;
             }
             WPAdm_Running::setCommandResultData('errors_sending', $data_error_command);
         } else {
             $send = false;
         }
     }
     if ($local) {
         $data_command = WPAdm_Running::getCommandResultData('command_dropbox');
         if (empty($data_command) || !in_array($fromFile, $data_command)) {
             if ($send) {
                 $res = $dropbox->uploadFile($fromFile, $toFile, true);
             } else {
                 $this->saveDataCommand($fromFile);
             }
         }
     } else {
         $res = $dropbox->uploadFile($fromFile, $toFile, true);
     }
     if (isset($res['error']) && isset($res['text']) && $res['error'] == 1) {
         $context->setError(langWPADM::get('Dropbox returned an error during file sending: ', false) . '"' . $res['text'] . '"');
         return false;
     }
     if (isset($res['size']) && isset($res['client_mtime'])) {
         WPAdm_Core::log(langWPADM::get('File upload: ', false) . basename($files) . langWPADM::get(' size: ', false) . $res['size']);
         $this->saveDataCommand($fromFile);
     }
     return true;
 }
开发者ID:derwegas,项目名称:strubbelkinder,代码行数:68,代码来源:class-wpadm-command-send-to-dropbox.php


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