本文整理汇总了PHP中dropbox::listing方法的典型用法代码示例。如果您正苦于以下问题:PHP dropbox::listing方法的具体用法?PHP dropbox::listing怎么用?PHP dropbox::listing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dropbox
的用法示例。
在下文中一共展示了dropbox::listing方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpadm_show_backup
public static function wpadm_show_backup()
{
require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
parent::$type = 'full';
$dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
if ($dropbox_options) {
$dropbox_options = unserialize(base64_decode($dropbox_options));
if (isset($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && isset($dropbox_options['auth_token_secret'])) {
$dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
$folder_project = self::getNameProject();
$backups = $dropbox->listing($folder_project);
$n = count($backups['items']);
$data['data'] = array();
for ($i = 0; $i < $n; $i++) {
$backup = $dropbox->listing($folder_project . "/" . $backups['items'][$i]['name']);
$data['data'][$i]['name'] = $backups['items'][$i]['name'];
$data['data'][$i]['size'] = (int) $backup['size'] * 1024 * 1024;
$data['data'][$i]['dt'] = parent::getDateInName($backups['items'][$i]['name']);
$data['data'][$i]['count'] = count($backup['items']);
$data['data'][$i]['type'] = 'dropbox';
$k = $data['data'][$i]['count'];
$data['data'][$i]['files'] = '[';
for ($j = 0; $j < $k; $j++) {
$data['data'][$i]['files'] .= $backup['items'][$i]['name'] . ',';
}
}
}
}
$data_local = parent::read_backups();
if (isset($data['data'])) {
$data['data'] = array_merge($data_local['data'], $data['data']);
$data['md5'] = md5(print_r($data['data'], 1));
} else {
$data = $data_local;
}
$show = !get_option('wpadm_pub_key') && is_super_admin();
$error = parent::getError(true);
$msg = parent::getMessage(true);
$base_path = DRBBACKUP_BASE_DIR;
ob_start();
require_once $base_path . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "wpadm_show_backup.php";
echo ob_get_clean();
}
示例2: wpadm_show_backup
public static function wpadm_show_backup()
{
require_once DRBBACKUP_BASE_DIR . "/modules/dropbox.class.php";
parent::$type = 'full';
$dropbox_options = get_option(PREFIX_BACKUP_ . 'dropbox-setting');
if ($dropbox_options) {
$dropbox_options = unserialize(base64_decode($dropbox_options));
if (isset($dropbox_options['app_key']) && isset($dropbox_options['app_secret']) && isset($dropbox_options['auth_token_secret'])) {
$dropbox = new dropbox($dropbox_options['app_key'], $dropbox_options['app_secret'], $dropbox_options['auth_token_secret']);
$folder_project = self::getNameProject();
$backups = $dropbox->listing($folder_project);
$n = count($backups['items']);
$data['data'] = array();
for ($i = 0; $i < $n; $i++) {
$backup = $dropbox->listing($folder_project . "/" . $backups['items'][$i]['name']);
$data['data'][$i]['name'] = $backups['items'][$i]['name'];
$data['data'][$i]['size'] = (double) $backup['size'] * 1024 * 1024;
$data['data'][$i]['dt'] = parent::getDateInName($backups['items'][$i]['name']);
$data['data'][$i]['count'] = count($backup['items']);
$data['data'][$i]['type'] = 'dropbox';
$k = $data['data'][$i]['count'];
$data['data'][$i]['files'] = '[';
for ($j = 0; $j < $k; $j++) {
$data['data'][$i]['files'] .= $backup['items'][$j]['name'] . ',';
}
}
}
}
if (isset($_GET['pay']) && $_GET['pay'] == 'success') {
if (!file_exists(WPAdm_Core::getTmpDir() . "/pay_success")) {
file_put_contents(WPAdm_Core::getTmpDir() . "/pay_success", 1);
parent::setMessage(langWPADM::get('', false));
}
}
if (isset($_GET['pay']) && $_GET['pay'] == 'cancel') {
parent::setError(langWPADM::get('Checkout was canceled', false));
}
$data_local = parent::read_backups();
if (isset($data['data'])) {
$data['data'] = array_merge($data_local['data'], $data['data']);
$data['md5'] = md5(print_r($data['data'], 1));
} else {
$data = $data_local;
}
if (file_exists(WPAdm_Core::getTmpDir() . "/pay_success")) {
$plugin_info = get_plugins("/" . parent::$plugin_name);
$plugin_version = isset($plugin_info[parent::$plugin_name . '.php']['Version']) ? $plugin_info[parent::$plugin_name . '.php']['Version'] : '';
$data_server = parent::sendToServer(array('actApi' => "proBackupCheck", 'site' => home_url(), 'email' => get_option('admin_email'), 'plugin' => parent::$plugin_name, 'key' => '', 'plugin_version' => $plugin_version));
if (isset($data_server['status']) && $data_server['status'] == 'success' && isset($data_server['key'])) {
update_option(PREFIX_BACKUP_ . 'pro-key', $data_server['key']);
if (isset($data_server['url']) && !empty($data_server['url'])) {
parent::setMessage(str_replace('&s', $data_server['url'], langWPADM::get('The "Dropbox backup & restore PRO" version can be downloaded here <a href="&s">download</a>', false)));
}
}
}
if (!function_exists('get_plugins')) {
require_once ABSPATH . 'wp-admin/includes/plugin.php';
}
$stars5 = file_exists(WPAdm_Core::getTmpDir() . "/notice-star");
$plugin_data = array_values(get_plugins('/dropbox-backup'));
$is_runnig = WPAdm_Running::is_running();
$show = !get_option('wpadm_pub_key') && is_super_admin();
$error = parent::getError(true);
$msg = parent::getMessage(true);
$base_path = DRBBACKUP_BASE_DIR;
ob_start();
require_once $base_path . DIRECTORY_SEPARATOR . "template" . DIRECTORY_SEPARATOR . "wpadm_show_backup.php";
echo ob_get_clean();
}
示例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;
}