@@ -45,8 +45,9 @@ |
||
| 45 | 45 | foreach ($files as $file) {
|
| 46 | 46 | $file = str_replace('\\', '/', $file);
|
| 47 | 47 | // Ignore "." and ".." folders |
| 48 | - if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..')))
|
|
| 49 | - continue; |
|
| 48 | + if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) {
|
|
| 49 | + continue; |
|
| 50 | + } |
|
| 50 | 51 | $file = realpath($file); |
| 51 | 52 | if (is_dir($file) === true) {
|
| 52 | 53 | $a[] = array( |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | $zip->addEmptyDir(end($dir)); |
| 123 | 123 | } else {
|
| 124 | 124 | $zip->addFromString( |
| 125 | - end($dir).'/'.$i.'.jpg', |
|
| 125 | + end($dir) . '/' . $i . '.jpg', |
|
| 126 | 126 | file_get_contents($entry['file']) |
| 127 | 127 | ); |
| 128 | 128 | $i++; |
@@ -166,9 +166,9 @@ discard block |
||
| 166 | 166 | $zipfilename = ""; |
| 167 | 167 | if (isset($album_download_directory)) {
|
| 168 | 168 | //$zipfilename = 'libs/resources'.DIRECTORY_SEPARATOR.'albums'.DIRECTORY_SEPARATOR.'fb-album_'.date("Y-m-d").'_'.date("H-i-s");
|
| 169 | - $zipfilename = 'public/fb-album_'.date("Y-m-d").'_'.date("H-i-s");
|
|
| 169 | + $zipfilename = 'public/fb-album_' . date("Y-m-d") . '_' . date("H-i-s");
|
|
| 170 | 170 | |
| 171 | - $folder = dirname($_SERVER['PHP_SELF']).'/'.$album_download_directory; |
|
| 171 | + $folder = dirname($_SERVER['PHP_SELF']) . '/' . $album_download_directory; |
|
| 172 | 172 | // Server Root |
| 173 | 173 | $root = $_SERVER["DOCUMENT_ROOT"]; |
| 174 | 174 | // source of the folder to unpack |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | * |
| 19 | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND |
| 20 | 20 | */ |
| 21 | -require_once __DIR__.'/../vendor/autoload.php'; |
|
| 21 | +require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 22 | 22 | session_start(); |
| 23 | 23 | /** |
| 24 | 24 | * Create a google Client for move album to Drive |
@@ -19,10 +19,10 @@ |
||
| 19 | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND |
| 20 | 20 | */ |
| 21 | 21 | require_once 'gClient.php'; |
| 22 | -$gClient =new CreateGoogleClient(); |
|
| 22 | +$gClient = new CreateGoogleClient(); |
|
| 23 | 23 | $client = $gClient->createClient(); |
| 24 | 24 | |
| 25 | -if (! isset($_GET['code'])) {
|
|
| 25 | +if (!isset($_GET['code'])) {
|
|
| 26 | 26 | $auth_url = $client->createAuthUrl(); |
| 27 | 27 | header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
|
| 28 | 28 | } else {
|
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | header('Location: https://localhost:8443/SociaManager/login.php');
|
| 31 | 31 | exit(); |
| 32 | 32 | } |
| 33 | - } catch(Facebook\Exceptions\FacebookResponseException $e) {
|
|
| 33 | + } catch (Facebook\Exceptions\FacebookResponseException $e) {
|
|
| 34 | 34 | // When Graph returns an error |
| 35 | 35 | echo 'Graph returned an error: ' . $e->getMessage(); |
| 36 | 36 | exit; |
| 37 | - } catch(Facebook\Exceptions\FacebookSDKException $e) {
|
|
| 37 | + } catch (Facebook\Exceptions\FacebookSDKException $e) {
|
|
| 38 | 38 | // When validation fails or other local issues |
| 39 | 39 | echo 'Facebook SDK returned an error: ' . $e->getMessage(); |
| 40 | 40 | exit; |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | // If you know the user ID this access token belongs to, you can validate it here |
| 52 | 52 | $tokenMetadata->validateExpiration(); |
| 53 | 53 | |
| 54 | - if (! $accessToken->isLongLived()) {
|
|
| 54 | + if (!$accessToken->isLongLived()) {
|
|
| 55 | 55 | // Exchanges a short-lived access token for a long-lived one |
| 56 | 56 | try {
|
| 57 | 57 | $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken); |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | * |
| 18 | 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND |
| 19 | 19 | */ |
| 20 | - require_once __DIR__ . "/config.php"; |
|
| 20 | + require_once __DIR__ . "/config.php"; |
|
| 21 | 21 | |
| 22 | 22 | if (isset($_SESSION['accessToken'])) {
|
| 23 | 23 | header('Location: https://localhost:8443/SociaManager/index.php');
|
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | header('Location: https://localhost:8443/SociaManager/index.php');
|
| 24 | 24 | exit(); |
| 25 | 25 | } |
| 26 | -$permissions = ['email','user_gender','user_location','user_photos']; |
|
| 26 | +$permissions = ['email', 'user_gender', 'user_location', 'user_photos']; |
|
| 27 | 27 | $loginUrl = $helper->getLoginUrl( |
| 28 | 28 | 'https://localhost:8443/SociaManager/index.php', |
| 29 | 29 | $permissions |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | ); |
| 25 | 25 | $userData = $response->getGraphNode()->asArray(); |
| 26 | 26 | $_SESSION['userid'] = $userData['id']; |
| 27 | -$_SESSION['email']=$userData['email']; |
|
| 27 | +$_SESSION['email'] = $userData['email']; |
|
| 28 | 28 | ?> |
| 29 | 29 | |
| 30 | 30 | <!DOCTYPE html> |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | <img src="<?php echo $userData['picture']['url'] ?>" alt="Profile Picture" class="circle"> |
| 95 | 95 | </a> |
| 96 | 96 | <a href="#"> |
| 97 | - <span class="name white-text"><?php echo $userData['first_name'] ." ".$userData['last_name'] ?></span> |
|
| 97 | + <span class="name white-text"><?php echo $userData['first_name'] . " " . $userData['last_name'] ?></span> |
|
| 98 | 98 | </a> |
| 99 | 99 | <a href="#"> |
| 100 | 100 | <span class="email white-text"><?php echo $userData['email'] ?></span> |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | <div class="profilepic"> |
| 128 | 128 | <img style="margin-top: 100px;" height="100" width="100" src="<?php echo $userData['picture']['url'] ?>" alt="Profile Picture" class="materialboxed circle responsive-img"> |
| 129 | 129 | </div> |
| 130 | - <p class="center teal-text" style="font-size: 25px;"><strong><?php echo $userData['first_name'] ." ". $userData['last_name'] ?></strong><p> |
|
| 130 | + <p class="center teal-text" style="font-size: 25px;"><strong><?php echo $userData['first_name'] . " " . $userData['last_name'] ?></strong><p> |
|
| 131 | 131 | <center> |
| 132 | 132 | </div> |
| 133 | 133 | <div class="col l6 profile-detaile"> |
@@ -174,13 +174,13 @@ discard block |
||
| 174 | 174 | </div> |
| 175 | 175 | <div class="card-content"> |
| 176 | 176 | <center> |
| 177 | - <button type="button" rel="<?php echo $albumm['id'].','.$albumm['name'];?>" class="btn waves-effect waves-light red single-download"><i class="material-icons">get_app</i></button><br/><br/> |
|
| 178 | - <button type="button" rel="<?php echo $albumm['id'].','.$albumm['name'];?>" class="btn waves-effect waves-light single-export">Export Album</button><br/><br/> |
|
| 177 | + <button type="button" rel="<?php echo $albumm['id'] . ',' . $albumm['name']; ?>" class="btn waves-effect waves-light red single-download"><i class="material-icons">get_app</i></button><br/><br/> |
|
| 178 | + <button type="button" rel="<?php echo $albumm['id'] . ',' . $albumm['name']; ?>" class="btn waves-effect waves-light single-export">Export Album</button><br/><br/> |
|
| 179 | 179 | |
| 180 | - <input type="checkbox" class="select-album" value="<?php echo $albumm['id'].','.$albumm['name'];?>" class="filled-in" /> |
|
| 180 | + <input type="checkbox" class="select-album" value="<?php echo $albumm['id'] . ',' . $albumm['name']; ?>" class="filled-in" /> |
|
| 181 | 181 | <br/> |
| 182 | - <span class="card-title"><?php echo $albumm['name'];?></span> |
|
| 183 | - <button type="button" rel="<?php echo $albumm['id'].','.$albumm['name'];?>" class="btn waves-effect waves-light blue move-single-album">Move to Drive</button> |
|
| 182 | + <span class="card-title"><?php echo $albumm['name']; ?></span> |
|
| 183 | + <button type="button" rel="<?php echo $albumm['id'] . ',' . $albumm['name']; ?>" class="btn waves-effect waves-light blue move-single-album">Move to Drive</button> |
|
| 184 | 184 | <br/> |
| 185 | 185 | <!-- <form id="uploadimage" action="" method="post" enctype="multipart/form-data"> |
| 186 | 186 | <center> |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | </div> |
| 240 | 240 | |
| 241 | 241 | <?php |
| 242 | - $google_access_token= ""; |
|
| 242 | + $google_access_token = ""; |
|
| 243 | 243 | if (isset($_SESSION['google_access_token'])) {
|
| 244 | 244 | $google_access_token = $_SESSION['google_access_token']; |
| 245 | 245 | } |
| 246 | 246 | ?> |
| 247 | 247 | |
| 248 | - <div id="" class="g-access-token"><?php if($google_access_token) echo "Hello"; else echo ""; ?></div> |
|
| 248 | + <div id="" class="g-access-token"><?php if ($google_access_token) echo "Hello"; else echo ""; ?></div> |
|
| 249 | 249 | |
| 250 | 250 | <!-- Footer --> |
| 251 | 251 | |
@@ -245,7 +245,12 @@ |
||
| 245 | 245 | } |
| 246 | 246 | ?> |
| 247 | 247 | |
| 248 | - <div id="" class="g-access-token"><?php if($google_access_token) echo "Hello"; else echo ""; ?></div> |
|
| 248 | + <div id="" class="g-access-token"><?php if($google_access_token) {
|
|
| 249 | + echo "Hello"; |
|
| 250 | +} else {
|
|
| 251 | + echo ""; |
|
| 252 | +} |
|
| 253 | +?></div> |
|
| 249 | 254 | |
| 250 | 255 | <!-- Footer --> |
| 251 | 256 | |
@@ -22,12 +22,12 @@ |
||
| 22 | 22 | if (isset($_GET['albumId'])) { |
| 23 | 23 | $albumId = $_GET['albumId']; |
| 24 | 24 | $response_albums = $fb->get($albumId . "/photos?fields=images,id&limit=500", $accessToken); |
| 25 | - $albums=$response_albums->getGraphEdge()->asArray(); |
|
| 26 | - $slides =""; |
|
| 25 | + $albums = $response_albums->getGraphEdge()->asArray(); |
|
| 26 | + $slides = ""; |
|
| 27 | 27 | foreach ($albums as $album) { |
| 28 | 28 | $albumUrl = $album['images'][0]['source']; |
| 29 | 29 | $slides .= '<div class="mySlides fade">'; |
| 30 | - $slides .= '<img src="'. $albumUrl .'" style="width:100%; height: 450px"></div>'; |
|
| 30 | + $slides .= '<img src="' . $albumUrl . '" style="width:100%; height: 450px"></div>'; |
|
| 31 | 31 | } |
| 32 | 32 | echo $slides; |
| 33 | 33 | } |
@@ -19,10 +19,10 @@ discard block |
||
| 19 | 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND |
| 20 | 20 | */ |
| 21 | 21 | ini_set('max_execution_time', 999999);
|
| 22 | -require_once __DIR__.'/gClient.php'; |
|
| 22 | +require_once __DIR__ . '/gClient.php'; |
|
| 23 | 23 | require_once "../fb-callback.php"; |
| 24 | 24 | |
| 25 | -$gClient =new CreateGoogleClient(); |
|
| 25 | +$gClient = new CreateGoogleClient(); |
|
| 26 | 26 | $client = $gClient->createClient(); |
| 27 | 27 | |
| 28 | 28 | if (isset($_SESSION['google_access_token']) && $_SESSION['google_access_token']) {
|
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | $drive = new Google_Service_Drive($client); |
| 32 | 32 | |
| 33 | - $rootFolderName = 'facebook_'.$_SESSION['userid'].'_albums'; |
|
| 33 | + $rootFolderName = 'facebook_' . $_SESSION['userid'] . '_albums'; |
|
| 34 | 34 | $fileMetaData = new Google_Service_Drive_DriveFile( |
| 35 | 35 | array( |
| 36 | 36 | 'name' => $rootFolderName, |
@@ -67,14 +67,14 @@ discard block |
||
| 67 | 67 | array('fields' => 'id')
|
| 68 | 68 | ); |
| 69 | 69 | |
| 70 | - $request_albums_photo = $fb->get($albumId ."/photos?fields=images&limit=5", $accessToken); |
|
| 70 | + $request_albums_photo = $fb->get($albumId . "/photos?fields=images&limit=5", $accessToken); |
|
| 71 | 71 | $arr_alb = $request_albums_photo->getGraphEdge(); |
| 72 | 72 | $i = 0; |
| 73 | 73 | $resultAlbum = getAlbum($fb, $arr_alb, $i); |
| 74 | 74 | $count = 1; |
| 75 | 75 | foreach ($resultAlbum as $images) {
|
| 76 | 76 | $url = $images['images']; |
| 77 | - $img = $count.".jpeg"; |
|
| 77 | + $img = $count . ".jpeg"; |
|
| 78 | 78 | $folderId = $SubFolder->id; |
| 79 | 79 | $fileMetadata = new Google_Service_Drive_DriveFile( |
| 80 | 80 | array( |
@@ -89,14 +89,14 @@ discard block |
||
| 89 | 89 | 'data' => $fileContent, 'mimeType' => 'image/jpeg', |
| 90 | 90 | 'uploadType' => 'multipart', 'fields' => 'id') |
| 91 | 91 | ); |
| 92 | - }catch (Exception $e) {
|
|
| 92 | + } catch (Exception $e) {
|
|
| 93 | 93 | print "An error occurred: " . $e->getMessage(); |
| 94 | 94 | } |
| 95 | 95 | $count++; |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - function getAlbum($fb,$arr_alb,$i) |
|
| 99 | + function getAlbum($fb, $arr_alb, $i) |
|
| 100 | 100 | {
|
| 101 | 101 | global $main_arr; |
| 102 | 102 | foreach ($arr_alb as $graphNode) {
|
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $i++; |
| 105 | 105 | } |
| 106 | 106 | $arr_alb_ar = $fb->next($arr_alb); |
| 107 | - if(!empty($arr_alb_ar)) {
|
|
| 107 | + if (!empty($arr_alb_ar)) {
|
|
| 108 | 108 | getAlbum($fb, $arr_alb_ar, $i); |
| 109 | 109 | } |
| 110 | 110 | return $main_arr; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | if (isset($_GET['selected_albums']) && !empty($_GET['selected_albums'])) {
|
| 129 | 129 | $response = '<span>Sorry due to some reasons albums is not moved to goofle drive.</span>'; |
| 130 | 130 | $selected_albums = explode("-", $_GET['selected_albums']);
|
| 131 | - foreach ( $selected_albums as $selected_album ) {
|
|
| 131 | + foreach ($selected_albums as $selected_album) {
|
|
| 132 | 132 | $selected_album = explode(",", $selected_album);
|
| 133 | 133 | moveToDrive( |
| 134 | 134 | $accessToken, |
@@ -89,7 +89,7 @@ |
||
| 89 | 89 | 'data' => $fileContent, 'mimeType' => 'image/jpeg', |
| 90 | 90 | 'uploadType' => 'multipart', 'fields' => 'id') |
| 91 | 91 | ); |
| 92 | - }catch (Exception $e) {
|
|
| 92 | + } catch (Exception $e) {
|
|
| 93 | 93 | print "An error occurred: " . $e->getMessage(); |
| 94 | 94 | } |
| 95 | 95 | $count++; |
@@ -46,7 +46,7 @@ |
||
| 46 | 46 | ) {
|
| 47 | 47 | $album_directory = $album_download_directory.$album_name; |
| 48 | 48 | if (!file_exists($album_directory)) {
|
| 49 | - mkdir($album_directory, 0777); |
|
| 49 | + mkdir($album_directory, 0777); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | $request_albums_photo = $fb->get($album_id . "/photos?fields=images&limit=5", $accessToken); |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | require_once "fb-callback.php"; |
| 22 | 22 | |
| 23 | 23 | $zip_folder = ""; |
| 24 | -$album_download_directory = 'public/'.uniqid().'/'; |
|
| 24 | +$album_download_directory = 'public/' . uniqid() . '/'; |
|
| 25 | 25 | mkdir($album_download_directory, 0777, true); |
| 26 | 26 | |
| 27 | 27 | $main_arr = array(); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $album_name, |
| 45 | 45 | $fb |
| 46 | 46 | ) {
|
| 47 | - $album_directory = $album_download_directory.$album_name; |
|
| 47 | + $album_directory = $album_download_directory . $album_name; |
|
| 48 | 48 | if (!file_exists($album_directory)) {
|
| 49 | 49 | mkdir($album_directory, 0777); |
| 50 | 50 | } |
@@ -76,13 +76,13 @@ discard block |
||
| 76 | 76 | */ |
| 77 | 77 | function Export_album($accessToken, $album_id, $album_name, $fb) |
| 78 | 78 | {
|
| 79 | - $request_albums_photo = $fb->get($album_id ."/photos?fields=images&limit=5", $accessToken); |
|
| 79 | + $request_albums_photo = $fb->get($album_id . "/photos?fields=images&limit=5", $accessToken); |
|
| 80 | 80 | $arr_alb = $request_albums_photo->getGraphEdge(); |
| 81 | 81 | $i = 0; |
| 82 | 82 | $resultAlbum = getAlbum($fb, $arr_alb, $album_name, $i); |
| 83 | 83 | |
| 84 | 84 | $response_json = json_encode(array($album_name => $resultAlbum), JSON_PRETTY_PRINT); |
| 85 | - $jsonFilename = './public/jsonData/fb-album_'.date("Y-m-d").'_'.date("H-i-s").'.json';
|
|
| 85 | + $jsonFilename = './public/jsonData/fb-album_' . date("Y-m-d") . '_' . date("H-i-s") . '.json';
|
|
| 86 | 86 | $jsonFile = fopen($jsonFilename, "a") or die("Unable to open file!");
|
| 87 | 87 | fwrite($jsonFile, $response_json); |
| 88 | 88 | fclose($jsonFile); |