Issues (96)

functions.php (2 issues)

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