-
Notifications
You must be signed in to change notification settings - Fork 8
/
yandexDisk.php
82 lines (65 loc) · 1.78 KB
/
yandexDisk.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?
error_reporting( 0 );
//error_reporting( -1 );
//ini_set("display_errors", 1);
if ( !class_exists( 'webdav_client' ) )
{
require('class_webdav_client.php');
}
$wdc = new webdav_client();
$wdc->set_server( 'ssl://webdav.yandex.ru' );
$wdc->set_port( 443 );
$wdc->set_user( 'forpdfsending' );
$wdc->set_pass( '' );
// use HTTP/1.1
$wdc->set_protocol( 1 );
// enable debugging
$wdc->set_debug( false );
if ( !$wdc->open() )
{
print 'Error: could not open server connection <br /> \r\n';
exit;
}
// check if server supports webdav rfc 2518
if ( !$wdc->check_webdav() )
{
print 'Error: server does not support webdav or user/password may be wrong <br /> \r\n';
exit;
}
$http_status = $wdc->mkcol( "/backups" );
$http_status = $wdc->put_file( "/backups/" . "test.zip", "test.zip" );
print 'webdav server returns ' . $http_status. "<br/ > \r\n";
$urlToThePublishedFile = $wdc->filePublish( "/backups/test.zip" );
print 'link to the published file: ' . $urlToThePublishedFile. "<br/ > \r\n";
$fileUnpublishinStatus = $wdc->fileUnPublish( "/backups/test.zip" );
if ( $fileUnpublishinStatus )
{
echo "File UnPublished correctly <br /> \r\n";
} else
{
echo "Some errors occured on file UnPublish <br /> \r\n";
}
if ( $wdc->get_file( "/soutcast/woman/gogo/2_1.jpg", "1.jpg" ) )
{
Echo "returned true <br /> \r\n";
} else
{
Echo "returned false <br />\r\n";
}
if ( $wdc->get_file( "/soutcast/woman/gogo/2_2.jpg", "2.jpg" ) )
{
Echo "returned true <br />\r\n";
} else
{
Echo "returned false <br />\r\n";
}
if ( $wdc->get_file( "/soutcast/woman/gogo/1arhiv.rar", "1arhiv.rar" ) )
{
Echo "returned true <br />\r\n";
} else
{
Echo "returned false <br />\r\n";
}
$wdc->close();
flush();
?>