Completed
Push — master ( 0bd148...b4cd5d )
by Rakesh
13:42 queued 09:26
created

functions.php (5 issues)

1
<?php
2
session_start();
3
    require_once 'appconfig.php';
4
5
        use Facebook\GraphNodes\GraphObject;
6
        use Facebook\GraphNodes\GraphSessionInfo;
7
        use Facebook\Authentication\AccessToken;
8
        use Facebook\HttpClients\FacebookHttpable;
0 ignored issues
show
The type Facebook\HttpClients\FacebookHttpable was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
        use Facebook\HttpClients\FacebookCurl;
10
        use Facebook\HttpClients\FacebookCurlHttpClient;
11
        use Facebook\FacebookSession;
0 ignored issues
show
The type Facebook\FacebookSession was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
        use Facebook\Helpers\FacebookRedirectLoginHelper;
13
        use Facebook\FacebookRequest;
14
        use Facebook\FacebookResponse;
15
        use Facebook\Exceptions\FacebookSDKException;
16
        use Facebook\Exceptions\FacebookAuthorizationException;
17
18
    $session = $_SESSION['fb_access_token'];
19
20
    $zip_folder = "";
21
    $album_download_directory = 'lib/resources/albums/' . uniqid() . '/';
22
    mkdir($album_download_directory, 0777);
23
24
    function download_album($session, $album_download_directory, $album_id, $album_name) {
25
26
        $graphPhoLink = 
0 ignored issues
show
The assignment to $graphPhoLink is dead and can be removed.
Loading history...
27
$jsonData = 
0 ignored issues
show
The assignment to $jsonData is dead and can be removed.
Loading history...
28
$fbPhotoObj = 
0 ignored issues
show
The assignment to $fbPhotoObj is dead and can be removed.
Loading history...
29
30
        $request_album_photos = "https://graph.facebook.com/v3.3/{$album_id}/photos?fields=source,images,name&limit=100&access_token={$session}";
31
        $response_album_photos = file_get_contents($request_album_photos);			
32
        $album_photos = json_decode($response_album_photos, true, 512, JSON_BIGINT_AS_STRING);
33
34
        $album_directory = $album_download_directory . $album_name;
35
        if (!file_exists($album_directory)) {
36
            mkdir($album_directory, 0777);
37
        }
38
39
        $i = 1;
40
        foreach ($album_photos['data'] as $album_photo) {
41
            $album_photo = (array)$album_photo;
42
            file_put_contents($album_directory . '/' . $i . ".jpg", fopen($album_photo['source'], 'r'));
43
            $i++;
44
        }
45
    }
46
47
    //---------- For 1 album download -------------------------------------------------//
48
    if (isset($_GET['single_album']) && !empty ($_GET['single_album'])) {
49
        
50
        $single_album = explode(",", $_GET['single_album']);
51
        download_album($session, $album_download_directory, $single_album[0], $single_album[1]);
52
    }
53
	
54
    //---------- For Selected Albums download -----------------------------------------//
55
    if (isset($_GET['selected_albums']) and count($_GET['selected_albums']) > 0) {
56
        $selected_albums = explode("/", $_GET['selected_albums']);
57
58
        foreach ($selected_albums as $selected_album) {
59
            $selected_album = explode(",", $selected_album);
60
            download_album($session, $album_download_directory, $selected_album[0], $selected_album[1]);
61
        }
62
    }
63
64
    //---------- Download all album code -------------------------------------------------//
65
    if (isset($_GET['all_albums']) && !empty ($_GET['all_albums'])) {
66
        if ($_GET['all_albums'] == 'all_albums') {
67
68
            // graph api request for user data
69
			
70
            $request_albums = "https://graph.facebook.com/v3.3/me/albums?fields=id,name&access_token={$session}";
71
            $response_albums = file_get_contents($$request_albums);
72
			
73
            // get response
74
            $albums = json_decode($response_albums, true, 512, JSON_BIGINT_AS_STRING);
75
76
            if (!empty($albums)) {
77
                foreach ($albums['data'] as $album) {
78
                    $album = (array)$album;
79
                    download_album($session, $album_download_directory, $album['id'], $album['name']);
80
                }
81
            }
82
        }
83
    }
84
85
    if (isset($_GET['zip'])) {
86
        require_once('zipper.php');
87
        $zipper = new zipper();
88
        echo $zipper->get_zip($album_download_directory);
89
90
    } else {
91
92
        //$redirect = 'location:lib/move_to_picasa.php?album_download_directory='.$album_download_directory;
93
        //if ( isset( $_GET['ajax'] ) ) {
94
        //	$redirect = $redirect . '&ajax=1';
95
        //}
96
        //($redirect);
97
    }