@@ -47,7 +47,7 @@ |
||
| 47 | 47 | public function __construct($id, $secret) |
| 48 | 48 | { |
| 49 | 49 | if (!is_string($id) |
| 50 | - // Keeping this for BC. Integers greater than PHP_INT_MAX will make is_int() return false |
|
| 50 | + // Keeping this for BC. Integers greater than PHP_INT_MAX will make is_int() return false |
|
| 51 | 51 | && !is_int($id)) { |
| 52 | 52 | throw new FacebookSDKException('The "app_id" must be formatted as a string since many app ID\'s are greater than PHP_INT_MAX on some systems.'); |
| 53 | 53 | } |
@@ -602,8 +602,8 @@ |
||
| 602 | 602 | } while (!$chunk->isLastChunk()); |
| 603 | 603 | |
| 604 | 604 | return [ |
| 605 | - 'video_id' => $chunk->getVideoId(), |
|
| 606 | - 'success' => $uploader->finish($endpoint, $chunk->getUploadSessionId(), $metadata), |
|
| 605 | + 'video_id' => $chunk->getVideoId(), |
|
| 606 | + 'success' => $uploader->finish($endpoint, $chunk->getUploadSessionId(), $metadata), |
|
| 607 | 607 | ]; |
| 608 | 608 | } |
| 609 | 609 | |
@@ -106,10 +106,11 @@ |
||
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
| 109 | -if ( isset( $_GET['ajax'] ) ) |
|
| 109 | +if ( isset( $_GET['ajax'] ) ) { |
|
| 110 | 110 | echo $response; |
| 111 | -else |
|
| 111 | +} else { |
|
| 112 | 112 | header('location:../index.php?response='.$response); |
| 113 | +} |
|
| 113 | 114 | |
| 114 | 115 | |
| 115 | 116 | ?> |
@@ -5,10 +5,10 @@ discard block |
||
| 5 | 5 | //============ Google Move Code ======================// |
| 6 | 6 | |
| 7 | 7 | if ( isset( $_GET['album_download_directory'] ) ) { |
| 8 | - $album_download_directory = $_GET['album_download_directory']; |
|
| 9 | - $album_download_directory = '../'.$album_download_directory; |
|
| 8 | + $album_download_directory = $_GET['album_download_directory']; |
|
| 9 | + $album_download_directory = '../'.$album_download_directory; |
|
| 10 | 10 | } else { |
| 11 | - header('location:../index.php'); |
|
| 11 | + header('location:../index.php'); |
|
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | require_once 'Zend/autooad.php'; |
@@ -18,10 +18,10 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | |
| 20 | 20 | function getAuthSubHttpClient() { |
| 21 | - if ( isset( $_SESSION['google_session_token'] ) ) { |
|
| 22 | - $client = Zend_Gdata_AuthSub::getHttpClient( $_SESSION['google_session_token'] ); |
|
| 23 | - return $client; |
|
| 24 | - } |
|
| 21 | + if ( isset( $_SESSION['google_session_token'] ) ) { |
|
| 22 | + $client = Zend_Gdata_AuthSub::getHttpClient( $_SESSION['google_session_token'] ); |
|
| 23 | + return $client; |
|
| 24 | + } |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | $gp = new Zend_Gdata_Photos(getAuthSubHttpClient(), "Google-DevelopersGuide-1.0"); |
@@ -29,87 +29,87 @@ discard block |
||
| 29 | 29 | |
| 30 | 30 | |
| 31 | 31 | function add_new_album( $entry, $gp, $album_download_directory, $album_name ) { |
| 32 | - $new_album_name = str_replace( " ", "_", $album_name ); |
|
| 33 | - $new_album_name = $new_album_name.'_'.uniqid(); |
|
| 34 | - |
|
| 35 | - $entry->setTitle( $gp->newTitle( $new_album_name ) ); |
|
| 36 | - $entry->setSummary( $gp->newSummary("Album added by Facebook Album Challenge") ); |
|
| 37 | - $gp->insertAlbumEntry( $entry ); |
|
| 38 | - |
|
| 39 | - $path = $album_download_directory.$album_name; |
|
| 40 | - if ( file_exists( $path ) ) { |
|
| 41 | - $photos = scandir( $path ); |
|
| 42 | - |
|
| 43 | - foreach ( $photos as $photo ) { |
|
| 44 | - if ( $photo != "." && $photo != ".." ) { |
|
| 45 | - $photo_path = $path.'/'.$photo; |
|
| 46 | - add_new_photo_to_album( $gp, $photo_path, $new_album_name ); |
|
| 47 | - } |
|
| 48 | - } |
|
| 49 | - } |
|
| 32 | + $new_album_name = str_replace( " ", "_", $album_name ); |
|
| 33 | + $new_album_name = $new_album_name.'_'.uniqid(); |
|
| 34 | + |
|
| 35 | + $entry->setTitle( $gp->newTitle( $new_album_name ) ); |
|
| 36 | + $entry->setSummary( $gp->newSummary("Album added by Facebook Album Challenge") ); |
|
| 37 | + $gp->insertAlbumEntry( $entry ); |
|
| 38 | + |
|
| 39 | + $path = $album_download_directory.$album_name; |
|
| 40 | + if ( file_exists( $path ) ) { |
|
| 41 | + $photos = scandir( $path ); |
|
| 42 | + |
|
| 43 | + foreach ( $photos as $photo ) { |
|
| 44 | + if ( $photo != "." && $photo != ".." ) { |
|
| 45 | + $photo_path = $path.'/'.$photo; |
|
| 46 | + add_new_photo_to_album( $gp, $photo_path, $new_album_name ); |
|
| 47 | + } |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | function add_new_photo_to_album( $gp, $path, $new_album_name ) { |
| 53 | - $user_name = "default"; |
|
| 54 | - $file_name = $path; |
|
| 55 | - $photo_name = "Photo added by Facebook Album Challenge"; |
|
| 56 | - $photo_caption = "Photo added by Facebook Album Challenge"; |
|
| 57 | - $photo_tags = "Photo, Facebook-Album-Challenge"; |
|
| 58 | - |
|
| 59 | - $fd = $gp->newMediaFileSource( $file_name ); |
|
| 60 | - $fd->setContentType("image/jpeg"); |
|
| 61 | - |
|
| 62 | - // Create a PhotoEntry |
|
| 63 | - $photo_entry = $gp->newPhotoEntry(); |
|
| 64 | - |
|
| 65 | - $photo_entry->setMediaSource( $fd ); |
|
| 66 | - $photo_entry->setTitle( $gp->newTitle( $photo_name ) ); |
|
| 67 | - $photo_entry->setSummary( $gp->newSummary( $photo_caption ) ); |
|
| 68 | - |
|
| 69 | - // add some tags |
|
| 70 | - $photo_media = new Zend_Gdata_Media_Extension_MediaKeywords(); |
|
| 71 | - $photo_media->setText( $photo_tags ); |
|
| 72 | - $photo_entry->mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup(); |
|
| 73 | - $photo_entry->mediaGroup->keywords = $photo_media; |
|
| 74 | - |
|
| 75 | - // We use the AlbumQuery class to generate the URL for the album |
|
| 76 | - $album_query = $gp->newAlbumQuery(); |
|
| 77 | - |
|
| 78 | - $album_query->setUser( $user_name ); |
|
| 79 | - //$albumQuery->setAlbumId($albumId); |
|
| 80 | - $album_query->setAlbumName( $new_album_name ); |
|
| 81 | - |
|
| 82 | - // We insert the photo, and the server returns the entry representing |
|
| 83 | - // that photo after it is uploaded |
|
| 84 | - //$insertedEntry = $gp->insertPhotoEntry( $photoEntry, $albumQuery->getQueryUrl() ); |
|
| 85 | - $gp->insertPhotoEntry( $photo_entry, $album_query->getQueryUrl() ); |
|
| 53 | + $user_name = "default"; |
|
| 54 | + $file_name = $path; |
|
| 55 | + $photo_name = "Photo added by Facebook Album Challenge"; |
|
| 56 | + $photo_caption = "Photo added by Facebook Album Challenge"; |
|
| 57 | + $photo_tags = "Photo, Facebook-Album-Challenge"; |
|
| 58 | + |
|
| 59 | + $fd = $gp->newMediaFileSource( $file_name ); |
|
| 60 | + $fd->setContentType("image/jpeg"); |
|
| 61 | + |
|
| 62 | + // Create a PhotoEntry |
|
| 63 | + $photo_entry = $gp->newPhotoEntry(); |
|
| 64 | + |
|
| 65 | + $photo_entry->setMediaSource( $fd ); |
|
| 66 | + $photo_entry->setTitle( $gp->newTitle( $photo_name ) ); |
|
| 67 | + $photo_entry->setSummary( $gp->newSummary( $photo_caption ) ); |
|
| 68 | + |
|
| 69 | + // add some tags |
|
| 70 | + $photo_media = new Zend_Gdata_Media_Extension_MediaKeywords(); |
|
| 71 | + $photo_media->setText( $photo_tags ); |
|
| 72 | + $photo_entry->mediaGroup = new Zend_Gdata_Media_Extension_MediaGroup(); |
|
| 73 | + $photo_entry->mediaGroup->keywords = $photo_media; |
|
| 74 | + |
|
| 75 | + // We use the AlbumQuery class to generate the URL for the album |
|
| 76 | + $album_query = $gp->newAlbumQuery(); |
|
| 77 | + |
|
| 78 | + $album_query->setUser( $user_name ); |
|
| 79 | + //$albumQuery->setAlbumId($albumId); |
|
| 80 | + $album_query->setAlbumName( $new_album_name ); |
|
| 81 | + |
|
| 82 | + // We insert the photo, and the server returns the entry representing |
|
| 83 | + // that photo after it is uploaded |
|
| 84 | + //$insertedEntry = $gp->insertPhotoEntry( $photoEntry, $albumQuery->getQueryUrl() ); |
|
| 85 | + $gp->insertPhotoEntry( $photo_entry, $album_query->getQueryUrl() ); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | if ( isset( $album_download_directory ) ) { |
| 89 | - if ( file_exists( $album_download_directory ) ) { |
|
| 90 | - $album_names = scandir( $album_download_directory ); |
|
| 91 | - |
|
| 92 | - foreach ( $album_names as $album_name ) { |
|
| 93 | - if ( $album_name != "." && $album_name != "..") { |
|
| 94 | - add_new_album( $entry, $gp, $album_download_directory, $album_name ); |
|
| 95 | - } |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - $unlink_folder = rtrim( $album_download_directory, "/" ); |
|
| 99 | - require_once('../unlink_directory.php'); |
|
| 100 | - $unlink_directory = new unlink_directory(); |
|
| 101 | - $unlink_directory->remove_directory( $unlink_folder ); |
|
| 102 | - } |
|
| 103 | - $response = 1; |
|
| 89 | + if ( file_exists( $album_download_directory ) ) { |
|
| 90 | + $album_names = scandir( $album_download_directory ); |
|
| 91 | + |
|
| 92 | + foreach ( $album_names as $album_name ) { |
|
| 93 | + if ( $album_name != "." && $album_name != "..") { |
|
| 94 | + add_new_album( $entry, $gp, $album_download_directory, $album_name ); |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + $unlink_folder = rtrim( $album_download_directory, "/" ); |
|
| 99 | + require_once('../unlink_directory.php'); |
|
| 100 | + $unlink_directory = new unlink_directory(); |
|
| 101 | + $unlink_directory->remove_directory( $unlink_folder ); |
|
| 102 | + } |
|
| 103 | + $response = 1; |
|
| 104 | 104 | } else { |
| 105 | - $response = 0; |
|
| 105 | + $response = 0; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | |
| 109 | 109 | if ( isset( $_GET['ajax'] ) ) |
| 110 | - echo $response; |
|
| 110 | + echo $response; |
|
| 111 | 111 | else |
| 112 | - header('location:../index.php?response='.$response); |
|
| 112 | + header('location:../index.php?response='.$response); |
|
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | ?> |
@@ -8,15 +8,15 @@ discard block |
||
| 8 | 8 | Zend_Loader::loadClass('Zend_Gdata_AuthSub'); |
| 9 | 9 | |
| 10 | 10 | if ( isset( $_GET['token'] ) ) { |
| 11 | - $_SESSION['google_session_token'] = Zend_Gdata_AuthSub::getAuthSubSessionToken( $_GET['token'] ); |
|
| 11 | + $_SESSION['google_session_token'] = Zend_Gdata_AuthSub::getAuthSubSessionToken( $_GET['token'] ); |
|
| 12 | 12 | |
| 13 | - $params = ""; |
|
| 14 | - foreach($_GET as $key => $value){ |
|
| 15 | - $params = $params . $key . '=' . $value . '&'; |
|
| 16 | - } |
|
| 17 | - //$params = $params . 'ajax='; |
|
| 18 | - $params = rtrim( $params, '&' ); |
|
| 19 | - header("location:../download_album.php?".$params); |
|
| 13 | + $params = ""; |
|
| 14 | + foreach($_GET as $key => $value){ |
|
| 15 | + $params = $params . $key . '=' . $value . '&'; |
|
| 16 | + } |
|
| 17 | + //$params = $params . 'ajax='; |
|
| 18 | + $params = rtrim( $params, '&' ); |
|
| 19 | + header("location:../download_album.php?".$params); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | ?> |
@@ -59,38 +59,38 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | <div class="container"> |
| 61 | 61 | <?php |
| 62 | - //============ Google Move Code ======================// |
|
| 62 | + //============ Google Move Code ======================// |
|
| 63 | 63 | |
| 64 | - function getCurrentUrl() { |
|
| 65 | - global $_SERVER; |
|
| 64 | + function getCurrentUrl() { |
|
| 65 | + global $_SERVER; |
|
| 66 | 66 | |
| 67 | - $php_request_uri = htmlentities(substr($_SERVER['REQUEST_URI'], 0, |
|
| 68 | - strcspn($_SERVER['REQUEST_URI'], "\n\r")), ENT_QUOTES); |
|
| 67 | + $php_request_uri = htmlentities(substr($_SERVER['REQUEST_URI'], 0, |
|
| 68 | + strcspn($_SERVER['REQUEST_URI'], "\n\r")), ENT_QUOTES); |
|
| 69 | 69 | |
| 70 | - if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') { |
|
| 71 | - $protocol = 'https://'; |
|
| 72 | - } else { |
|
| 73 | - $protocol = 'http://'; |
|
| 74 | - } |
|
| 75 | - $host = $_SERVER['HTTP_HOST']; |
|
| 76 | - if ($_SERVER['SERVER_PORT'] != '' && |
|
| 77 | - (($protocol == 'http://' && $_SERVER['SERVER_PORT'] != '80') || |
|
| 78 | - ($protocol == 'https://' && $_SERVER['SERVER_PORT'] != '443'))) { |
|
| 79 | - $port = ':' . $_SERVER['SERVER_PORT']; |
|
| 80 | - } else { |
|
| 81 | - $port = ''; |
|
| 82 | - } |
|
| 83 | - return $protocol . $host . $port . $php_request_uri; |
|
| 84 | - } |
|
| 70 | + if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on') { |
|
| 71 | + $protocol = 'https://'; |
|
| 72 | + } else { |
|
| 73 | + $protocol = 'http://'; |
|
| 74 | + } |
|
| 75 | + $host = $_SERVER['HTTP_HOST']; |
|
| 76 | + if ($_SERVER['SERVER_PORT'] != '' && |
|
| 77 | + (($protocol == 'http://' && $_SERVER['SERVER_PORT'] != '80') || |
|
| 78 | + ($protocol == 'https://' && $_SERVER['SERVER_PORT'] != '443'))) { |
|
| 79 | + $port = ':' . $_SERVER['SERVER_PORT']; |
|
| 80 | + } else { |
|
| 81 | + $port = ''; |
|
| 82 | + } |
|
| 83 | + return $protocol . $host . $port . $php_request_uri; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - function getAuthSubUrl() { |
|
| 87 | - $next = getCurrentUrl(); |
|
| 88 | - $scope = 'http://picasaweb.google.com/data'; |
|
| 89 | - $secure = 0; |
|
| 90 | - $session = 1; |
|
| 91 | - return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); |
|
| 92 | - } |
|
| 93 | - ?> |
|
| 86 | + function getAuthSubUrl() { |
|
| 87 | + $next = getCurrentUrl(); |
|
| 88 | + $scope = 'http://picasaweb.google.com/data'; |
|
| 89 | + $secure = 0; |
|
| 90 | + $session = 1; |
|
| 91 | + return Zend_Gdata_AuthSub::getAuthSubTokenUri($next, $scope, $secure, $session); |
|
| 92 | + } |
|
| 93 | + ?> |
|
| 94 | 94 | |
| 95 | 95 | <div id="login-div" class="row"> |
| 96 | 96 | <a id="login-link" class="btn btn-danger btn-lg" href="<?php echo getAuthSubUrl();?>"> |
@@ -6,195 +6,195 @@ |
||
| 6 | 6 | |
| 7 | 7 | class zipper { |
| 8 | 8 | |
| 9 | - public function LoadZipFiles($source) { |
|
| 9 | + public function LoadZipFiles($source) { |
|
| 10 | 10 | |
| 11 | - if (!file_exists($source)) { |
|
| 12 | - return false; |
|
| 13 | - } |
|
| 11 | + if (!file_exists($source)) { |
|
| 12 | + return false; |
|
| 13 | + } |
|
| 14 | 14 | |
| 15 | - $source = str_replace('\\', '/', realpath($source)); |
|
| 15 | + $source = str_replace('\\', '/', realpath($source)); |
|
| 16 | 16 | |
| 17 | - $a = array(); |
|
| 17 | + $a = array(); |
|
| 18 | 18 | |
| 19 | - if (is_dir($source) === true) { |
|
| 20 | - $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST); |
|
| 19 | + if (is_dir($source) === true) { |
|
| 20 | + $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($source), RecursiveIteratorIterator::SELF_FIRST); |
|
| 21 | 21 | |
| 22 | - foreach ($files as $file) { |
|
| 23 | - $file = str_replace('\\', '/', $file); |
|
| 22 | + foreach ($files as $file) { |
|
| 23 | + $file = str_replace('\\', '/', $file); |
|
| 24 | 24 | |
| 25 | - // Ignore "." and ".." folders |
|
| 26 | - if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) |
|
| 27 | - continue; |
|
| 25 | + // Ignore "." and ".." folders |
|
| 26 | + if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) |
|
| 27 | + continue; |
|
| 28 | 28 | |
| 29 | - $file = realpath($file); |
|
| 29 | + $file = realpath($file); |
|
| 30 | 30 | |
| 31 | - if (is_dir($file) === true) { |
|
| 32 | - $a[] = array( |
|
| 33 | - 'type' => 'dir', |
|
| 34 | - 'source' => str_replace($source . '/', '', $file . '/'), |
|
| 35 | - 'file' => $file, |
|
| 36 | - 'size' => 0 |
|
| 37 | - ); |
|
| 38 | - } else if (is_file($file) === true) { |
|
| 39 | - $src = str_replace($source . '/', '', $file); |
|
| 40 | - $size = filesize($file); |
|
| 31 | + if (is_dir($file) === true) { |
|
| 32 | + $a[] = array( |
|
| 33 | + 'type' => 'dir', |
|
| 34 | + 'source' => str_replace($source . '/', '', $file . '/'), |
|
| 35 | + 'file' => $file, |
|
| 36 | + 'size' => 0 |
|
| 37 | + ); |
|
| 38 | + } else if (is_file($file) === true) { |
|
| 39 | + $src = str_replace($source . '/', '', $file); |
|
| 40 | + $size = filesize($file); |
|
| 41 | 41 | |
| 42 | - $a[] = array( |
|
| 43 | - 'type' => 'file', |
|
| 44 | - 'source' => $src, |
|
| 45 | - 'file' => $file, |
|
| 46 | - 'size' => false != $size ? $size : 16000 // this is fallback in case no size |
|
| 47 | - ); |
|
| 48 | - } |
|
| 49 | - } |
|
| 50 | - } |
|
| 42 | + $a[] = array( |
|
| 43 | + 'type' => 'file', |
|
| 44 | + 'source' => $src, |
|
| 45 | + 'file' => $file, |
|
| 46 | + 'size' => false != $size ? $size : 16000 // this is fallback in case no size |
|
| 47 | + ); |
|
| 48 | + } |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - return $a; |
|
| 53 | - } |
|
| 52 | + return $a; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function ProcessZip($foldercontent, $folder, $maxsize) { |
|
| 55 | + public function ProcessZip($foldercontent, $folder, $maxsize) { |
|
| 56 | 56 | |
| 57 | - $split = array(); |
|
| 57 | + $split = array(); |
|
| 58 | 58 | |
| 59 | - $splits = 1; |
|
| 60 | - $t = 0; |
|
| 59 | + $splits = 1; |
|
| 60 | + $t = 0; |
|
| 61 | 61 | |
| 62 | - // Determine how many zip files to create |
|
| 63 | - if ( isset( $foldercontent ) ) { |
|
| 64 | - foreach ($foldercontent as $entry) { |
|
| 62 | + // Determine how many zip files to create |
|
| 63 | + if ( isset( $foldercontent ) ) { |
|
| 64 | + foreach ($foldercontent as $entry) { |
|
| 65 | 65 | |
| 66 | - $t = $t + $entry['size']; |
|
| 66 | + $t = $t + $entry['size']; |
|
| 67 | 67 | |
| 68 | - if ($entry['type'] == 'dir') { |
|
| 69 | - $lastdir = $entry; |
|
| 70 | - } |
|
| 68 | + if ($entry['type'] == 'dir') { |
|
| 69 | + $lastdir = $entry; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - if ($t >= $maxsize) { |
|
| 73 | - $splits++; |
|
| 74 | - $t = 0; |
|
| 75 | - // create lastdir in next archive, in case files still exist |
|
| 76 | - // even if the next file is not in this archive it doesn't hurt |
|
| 77 | - if ($lastdir !== '') { |
|
| 78 | - $split[$splits][] = $lastdir; |
|
| 79 | - } |
|
| 80 | - } |
|
| 72 | + if ($t >= $maxsize) { |
|
| 73 | + $splits++; |
|
| 74 | + $t = 0; |
|
| 75 | + // create lastdir in next archive, in case files still exist |
|
| 76 | + // even if the next file is not in this archive it doesn't hurt |
|
| 77 | + if ($lastdir !== '') { |
|
| 78 | + $split[$splits][] = $lastdir; |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | - $split[$splits][] = $entry; |
|
| 83 | - } |
|
| 82 | + $split[$splits][] = $entry; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - // delete the $foldercontent array |
|
| 86 | - unset($foldercontent); |
|
| 85 | + // delete the $foldercontent array |
|
| 86 | + unset($foldercontent); |
|
| 87 | 87 | |
| 88 | - // Create the folder to put the zip files in |
|
| 89 | - $date = new DateTime(); |
|
| 90 | - $tS = $date->format('YmdHis'); |
|
| 88 | + // Create the folder to put the zip files in |
|
| 89 | + $date = new DateTime(); |
|
| 90 | + $tS = $date->format('YmdHis'); |
|
| 91 | 91 | |
| 92 | - // Process the splits |
|
| 93 | - foreach ($split as $idx => $sp) { |
|
| 92 | + // Process the splits |
|
| 93 | + foreach ($split as $idx => $sp) { |
|
| 94 | 94 | |
| 95 | - // create the zip file |
|
| 96 | - |
|
| 97 | - $zip = new ZipArchive(); |
|
| 98 | - |
|
| 99 | - $destination = $folder . '.zip'; |
|
| 100 | - |
|
| 101 | - if (!$zip->open($destination, ZIPARCHIVE::CREATE)) { |
|
| 102 | - return false; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - $i = 1; |
|
| 106 | - $dir = ""; |
|
| 107 | - foreach ($sp as $entry) { |
|
| 108 | - if ($entry['type'] === 'dir') { |
|
| 109 | - $dir = explode('\\', $entry['file']); |
|
| 110 | - $zip->addEmptyDir(end($dir)); |
|
| 111 | - } else { |
|
| 112 | - $zip->addFromString(end($dir).'/'.$i.'.jpg', file_get_contents($entry['file'])); |
|
| 113 | - $i++; |
|
| 114 | - } |
|
| 115 | - } |
|
| 116 | - $zip->close(); |
|
| 117 | - } |
|
| 118 | - return array( |
|
| 119 | - 'splits' => count($split), |
|
| 120 | - 'foldername' => '' |
|
| 121 | - ); |
|
| 122 | - } |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - public function getMemoryLimit() { |
|
| 126 | - $memory_limit = ini_get('memory_limit'); |
|
| 127 | - |
|
| 128 | - if (preg_match('/^(\d+)(.)$/', $memory_limit, $matches)) { |
|
| 129 | - if ($matches[2] == 'M') { |
|
| 130 | - $memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB |
|
| 131 | - } else if ($matches[2] == 'K') { |
|
| 132 | - $memory_limit = $matches[1] * 1024; // nnnK -> nnn KB |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - return $memory_limit; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - public function make_zip($album_download_directory) { |
|
| 140 | - $zipfilename = ""; |
|
| 141 | - if ( isset( $album_download_directory) ) { |
|
| 142 | - //$zipfilename = 'libs/resources'.DIRECTORY_SEPARATOR.'albums'.DIRECTORY_SEPARATOR.'fb-album_'.date("Y-m-d").'_'.date("H-i-s"); |
|
| 143 | - $zipfilename = 'lib/resources/albums/fb-album_'.date("Y-m-d").'_'.date("H-i-s"); |
|
| 144 | - |
|
| 145 | - // name of folder starting from the root of the webserver |
|
| 146 | - // as in Wordpress /wp-content/themes/ (end on backslash) |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - $folder = dirname($_SERVER['PHP_SELF']).'/'.$album_download_directory; |
|
| 150 | - |
|
| 151 | - // Server Root |
|
| 152 | - $root = $_SERVER["DOCUMENT_ROOT"]; |
|
| 153 | - |
|
| 154 | - // source of the folder to unpack |
|
| 155 | - $sourcedir = $root . $folder; // target directory |
|
| 156 | - |
|
| 157 | - // Don't use more than half the memory limit |
|
| 158 | - $memory_limit = $this->getMemoryLimit(); |
|
| 159 | - $maxsize = $memory_limit / 2; |
|
| 160 | - |
|
| 161 | - // Is zipping possible on the server ? |
|
| 162 | - if (!extension_loaded('zip')) { |
|
| 163 | - echo 'Zipping not possible on this server'; |
|
| 164 | - exit; |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - // Get the files to zip |
|
| 168 | - $foldercontent = $this->LoadZipFiles($sourcedir); |
|
| 169 | - if ($foldercontent === false) { |
|
| 170 | - echo 'Something went wrong gathering the file entries'; |
|
| 171 | - exit; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - // Process the files to zip |
|
| 175 | - $zip = $this->ProcessZip($foldercontent, $zipfilename, $maxsize); |
|
| 176 | - if ($zip === false) { |
|
| 177 | - echo 'Something went wrong zipping the files'; |
|
| 178 | - } |
|
| 95 | + // create the zip file |
|
| 96 | + |
|
| 97 | + $zip = new ZipArchive(); |
|
| 98 | + |
|
| 99 | + $destination = $folder . '.zip'; |
|
| 100 | + |
|
| 101 | + if (!$zip->open($destination, ZIPARCHIVE::CREATE)) { |
|
| 102 | + return false; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + $i = 1; |
|
| 106 | + $dir = ""; |
|
| 107 | + foreach ($sp as $entry) { |
|
| 108 | + if ($entry['type'] === 'dir') { |
|
| 109 | + $dir = explode('\\', $entry['file']); |
|
| 110 | + $zip->addEmptyDir(end($dir)); |
|
| 111 | + } else { |
|
| 112 | + $zip->addFromString(end($dir).'/'.$i.'.jpg', file_get_contents($entry['file'])); |
|
| 113 | + $i++; |
|
| 114 | + } |
|
| 115 | + } |
|
| 116 | + $zip->close(); |
|
| 117 | + } |
|
| 118 | + return array( |
|
| 119 | + 'splits' => count($split), |
|
| 120 | + 'foldername' => '' |
|
| 121 | + ); |
|
| 122 | + } |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + public function getMemoryLimit() { |
|
| 126 | + $memory_limit = ini_get('memory_limit'); |
|
| 127 | + |
|
| 128 | + if (preg_match('/^(\d+)(.)$/', $memory_limit, $matches)) { |
|
| 129 | + if ($matches[2] == 'M') { |
|
| 130 | + $memory_limit = $matches[1] * 1024 * 1024; // nnnM -> nnn MB |
|
| 131 | + } else if ($matches[2] == 'K') { |
|
| 132 | + $memory_limit = $matches[1] * 1024; // nnnK -> nnn KB |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + return $memory_limit; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + public function make_zip($album_download_directory) { |
|
| 140 | + $zipfilename = ""; |
|
| 141 | + if ( isset( $album_download_directory) ) { |
|
| 142 | + //$zipfilename = 'libs/resources'.DIRECTORY_SEPARATOR.'albums'.DIRECTORY_SEPARATOR.'fb-album_'.date("Y-m-d").'_'.date("H-i-s"); |
|
| 143 | + $zipfilename = 'lib/resources/albums/fb-album_'.date("Y-m-d").'_'.date("H-i-s"); |
|
| 144 | + |
|
| 145 | + // name of folder starting from the root of the webserver |
|
| 146 | + // as in Wordpress /wp-content/themes/ (end on backslash) |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + $folder = dirname($_SERVER['PHP_SELF']).'/'.$album_download_directory; |
|
| 150 | + |
|
| 151 | + // Server Root |
|
| 152 | + $root = $_SERVER["DOCUMENT_ROOT"]; |
|
| 153 | + |
|
| 154 | + // source of the folder to unpack |
|
| 155 | + $sourcedir = $root . $folder; // target directory |
|
| 156 | + |
|
| 157 | + // Don't use more than half the memory limit |
|
| 158 | + $memory_limit = $this->getMemoryLimit(); |
|
| 159 | + $maxsize = $memory_limit / 2; |
|
| 160 | + |
|
| 161 | + // Is zipping possible on the server ? |
|
| 162 | + if (!extension_loaded('zip')) { |
|
| 163 | + echo 'Zipping not possible on this server'; |
|
| 164 | + exit; |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + // Get the files to zip |
|
| 168 | + $foldercontent = $this->LoadZipFiles($sourcedir); |
|
| 169 | + if ($foldercontent === false) { |
|
| 170 | + echo 'Something went wrong gathering the file entries'; |
|
| 171 | + exit; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + // Process the files to zip |
|
| 175 | + $zip = $this->ProcessZip($foldercontent, $zipfilename, $maxsize); |
|
| 176 | + if ($zip === false) { |
|
| 177 | + echo 'Something went wrong zipping the files'; |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - // clear the stat cache (created by filesize command) |
|
| 181 | - clearstatcache(); |
|
| 180 | + // clear the stat cache (created by filesize command) |
|
| 181 | + clearstatcache(); |
|
| 182 | 182 | |
| 183 | - require_once( 'unlink_directory.php' ); |
|
| 184 | - $unlink_directory = new unlink_directory(); |
|
| 185 | - $unlink_directory->remove_directory( $album_download_directory ); |
|
| 186 | - } |
|
| 187 | - return $zipfilename; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - public function get_zip( $album_download_directory ) { |
|
| 191 | - $response = '<span style="color: #ffffff;">Sorry due to some reasons albums cannot be downloaded.</span>'; |
|
| 192 | - if ( isset( $album_download_directory ) ) { |
|
| 193 | - $zip_folder = $this->make_zip( $album_download_directory ); |
|
| 194 | - if ( !empty( $zip_folder ) ) { |
|
| 195 | - $response = '<a href="' . $zip_folder . '.zip" id="download-link" class="btn btn-success link-buttons-border-color" >Download Zip Folder</a>'; |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - return $response; |
|
| 199 | - } |
|
| 183 | + require_once( 'unlink_directory.php' ); |
|
| 184 | + $unlink_directory = new unlink_directory(); |
|
| 185 | + $unlink_directory->remove_directory( $album_download_directory ); |
|
| 186 | + } |
|
| 187 | + return $zipfilename; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + public function get_zip( $album_download_directory ) { |
|
| 191 | + $response = '<span style="color: #ffffff;">Sorry due to some reasons albums cannot be downloaded.</span>'; |
|
| 192 | + if ( isset( $album_download_directory ) ) { |
|
| 193 | + $zip_folder = $this->make_zip( $album_download_directory ); |
|
| 194 | + if ( !empty( $zip_folder ) ) { |
|
| 195 | + $response = '<a href="' . $zip_folder . '.zip" id="download-link" class="btn btn-success link-buttons-border-color" >Download Zip Folder</a>'; |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + return $response; |
|
| 199 | + } |
|
| 200 | 200 | } |
| 201 | 201 | \ No newline at end of file |
@@ -23,8 +23,9 @@ |
||
| 23 | 23 | $file = str_replace('\\', '/', $file); |
| 24 | 24 | |
| 25 | 25 | // Ignore "." and ".." folders |
| 26 | - if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) |
|
| 27 | - continue; |
|
| 26 | + if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..'))) { |
|
| 27 | + continue; |
|
| 28 | + } |
|
| 28 | 29 | |
| 29 | 30 | $file = realpath($file); |
| 30 | 31 | |
@@ -3,13 +3,13 @@ |
||
| 3 | 3 | require_once 'appconfig.php'; |
| 4 | 4 | |
| 5 | 5 | $fb = new Facebook\Facebook([ |
| 6 | - 'app_id' => $appId, // variable with Facebook App ID |
|
| 7 | - 'app_secret' => $appSecret, |
|
| 8 | - 'default_graph_version' => 'v3.3', |
|
| 9 | - ]); |
|
| 10 | - $helper = $fb->getRedirectLoginHelper(); |
|
| 11 | - $permissions = ['email','user_photos','user_videos','user_posts','user_link','user_status','user_link']; // Optional permissions |
|
| 12 | - $loginUrl = $helper->getLoginUrl($CallbackUrl,$permissions); |
|
| 6 | + 'app_id' => $appId, // variable with Facebook App ID |
|
| 7 | + 'app_secret' => $appSecret, |
|
| 8 | + 'default_graph_version' => 'v3.3', |
|
| 9 | + ]); |
|
| 10 | + $helper = $fb->getRedirectLoginHelper(); |
|
| 11 | + $permissions = ['email','user_photos','user_videos','user_posts','user_link','user_status','user_link']; // Optional permissions |
|
| 12 | + $loginUrl = $helper->getLoginUrl($CallbackUrl,$permissions); |
|
| 13 | 13 | |
| 14 | - echo "<h3> Connect Clicking Below Facebook Icon Using Your Facebook Account.<h3>"; |
|
| 15 | - echo '<a href="' .htmlspecialchars($loginUrl).'"><img alt="Login With Facebook" src="images/fb_icon.png"></a>'; |
|
| 16 | 14 | \ No newline at end of file |
| 15 | + echo "<h3> Connect Clicking Below Facebook Icon Using Your Facebook Account.<h3>"; |
|
| 16 | + echo '<a href="' .htmlspecialchars($loginUrl).'"><img alt="Login With Facebook" src="images/fb_icon.png"></a>'; |
|
| 17 | 17 | \ No newline at end of file |
@@ -9,10 +9,10 @@ |
||
| 9 | 9 | session_start(); |
| 10 | 10 | require_once 'appconfig.php'; |
| 11 | 11 | $fb = new Facebook\Facebook([ |
| 12 | - 'app_id' => $appId, // variable with Facebook App ID |
|
| 13 | - 'app_secret' => $appSecret, |
|
| 14 | - 'default_graph_version' => 'v3.3', |
|
| 15 | - ]); |
|
| 12 | + 'app_id' => $appId, // variable with Facebook App ID |
|
| 13 | + 'app_secret' => $appSecret, |
|
| 14 | + 'default_graph_version' => 'v3.3', |
|
| 15 | + ]); |
|
| 16 | 16 | $helper = $fb->getRedirectLoginHelper(); |
| 17 | 17 | try { |
| 18 | 18 | $accessToken = $helper->getAccessToken(); |
@@ -21,176 +21,176 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class Google_Utils_UriTemplate |
| 23 | 23 | { |
| 24 | - const TYPE_MAP = "1"; |
|
| 25 | - const TYPE_LIST = "2"; |
|
| 26 | - const TYPE_SCALAR = "4"; |
|
| 24 | + const TYPE_MAP = "1"; |
|
| 25 | + const TYPE_LIST = "2"; |
|
| 26 | + const TYPE_SCALAR = "4"; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @var $operators array |
|
| 30 | - * These are valid at the start of a template block to |
|
| 31 | - * modify the way in which the variables inside are |
|
| 32 | - * processed. |
|
| 33 | - */ |
|
| 34 | - private $operators = array( |
|
| 35 | - "+" => "reserved", |
|
| 36 | - "/" => "segments", |
|
| 37 | - "." => "dotprefix", |
|
| 38 | - "#" => "fragment", |
|
| 39 | - ";" => "semicolon", |
|
| 40 | - "?" => "form", |
|
| 41 | - "&" => "continuation" |
|
| 42 | - ); |
|
| 28 | + /** |
|
| 29 | + * @var $operators array |
|
| 30 | + * These are valid at the start of a template block to |
|
| 31 | + * modify the way in which the variables inside are |
|
| 32 | + * processed. |
|
| 33 | + */ |
|
| 34 | + private $operators = array( |
|
| 35 | + "+" => "reserved", |
|
| 36 | + "/" => "segments", |
|
| 37 | + "." => "dotprefix", |
|
| 38 | + "#" => "fragment", |
|
| 39 | + ";" => "semicolon", |
|
| 40 | + "?" => "form", |
|
| 41 | + "&" => "continuation" |
|
| 42 | + ); |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @var reserved array |
|
| 46 | - * These are the characters which should not be URL encoded in reserved |
|
| 47 | - * strings. |
|
| 48 | - */ |
|
| 49 | - private $reserved = array( |
|
| 50 | - "=", ",", "!", "@", "|", ":", "/", "?", "#", |
|
| 51 | - "[", "]",'$', "&", "'", "(", ")", "*", "+", ";" |
|
| 52 | - ); |
|
| 53 | - private $reservedEncoded = array( |
|
| 44 | + /** |
|
| 45 | + * @var reserved array |
|
| 46 | + * These are the characters which should not be URL encoded in reserved |
|
| 47 | + * strings. |
|
| 48 | + */ |
|
| 49 | + private $reserved = array( |
|
| 50 | + "=", ",", "!", "@", "|", ":", "/", "?", "#", |
|
| 51 | + "[", "]",'$', "&", "'", "(", ")", "*", "+", ";" |
|
| 52 | + ); |
|
| 53 | + private $reservedEncoded = array( |
|
| 54 | 54 | "%3D", "%2C", "%21", "%40", "%7C", "%3A", "%2F", "%3F", |
| 55 | 55 | "%23", "%5B", "%5D", "%24", "%26", "%27", "%28", "%29", |
| 56 | 56 | "%2A", "%2B", "%3B" |
| 57 | - ); |
|
| 57 | + ); |
|
| 58 | 58 | |
| 59 | - public function parse($string, array $parameters) |
|
| 60 | - { |
|
| 59 | + public function parse($string, array $parameters) |
|
| 60 | + { |
|
| 61 | 61 | return $this->resolveNextSection($string, $parameters); |
| 62 | - } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * This function finds the first matching {...} block and |
|
| 66 | - * executes the replacement. It then calls itself to find |
|
| 67 | - * subsequent blocks, if any. |
|
| 68 | - */ |
|
| 69 | - private function resolveNextSection($string, $parameters) |
|
| 70 | - { |
|
| 64 | + /** |
|
| 65 | + * This function finds the first matching {...} block and |
|
| 66 | + * executes the replacement. It then calls itself to find |
|
| 67 | + * subsequent blocks, if any. |
|
| 68 | + */ |
|
| 69 | + private function resolveNextSection($string, $parameters) |
|
| 70 | + { |
|
| 71 | 71 | $start = strpos($string, "{"); |
| 72 | 72 | if ($start === false) { |
| 73 | - return $string; |
|
| 73 | + return $string; |
|
| 74 | 74 | } |
| 75 | 75 | $end = strpos($string, "}"); |
| 76 | 76 | if ($end === false) { |
| 77 | - return $string; |
|
| 77 | + return $string; |
|
| 78 | 78 | } |
| 79 | 79 | $string = $this->replace($string, $start, $end, $parameters); |
| 80 | 80 | return $this->resolveNextSection($string, $parameters); |
| 81 | - } |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - private function replace($string, $start, $end, $parameters) |
|
| 84 | - { |
|
| 83 | + private function replace($string, $start, $end, $parameters) |
|
| 84 | + { |
|
| 85 | 85 | // We know a data block will have {} round it, so we can strip that. |
| 86 | 86 | $data = substr($string, $start + 1, $end - $start - 1); |
| 87 | 87 | |
| 88 | 88 | // If the first character is one of the reserved operators, it effects |
| 89 | 89 | // the processing of the stream. |
| 90 | 90 | if (isset($this->operators[$data[0]])) { |
| 91 | - $op = $this->operators[$data[0]]; |
|
| 92 | - $data = substr($data, 1); |
|
| 93 | - $prefix = ""; |
|
| 94 | - $prefix_on_missing = false; |
|
| 91 | + $op = $this->operators[$data[0]]; |
|
| 92 | + $data = substr($data, 1); |
|
| 93 | + $prefix = ""; |
|
| 94 | + $prefix_on_missing = false; |
|
| 95 | 95 | |
| 96 | - switch ($op) { |
|
| 96 | + switch ($op) { |
|
| 97 | 97 | case "reserved": |
| 98 | 98 | // Reserved means certain characters should not be URL encoded |
| 99 | 99 | $data = $this->replaceVars($data, $parameters, ",", null, true); |
| 100 | - break; |
|
| 100 | + break; |
|
| 101 | 101 | case "fragment": |
| 102 | 102 | // Comma separated with fragment prefix. Bare values only. |
| 103 | 103 | $prefix = "#"; |
| 104 | - $prefix_on_missing = true; |
|
| 105 | - $data = $this->replaceVars($data, $parameters, ",", null, true); |
|
| 106 | - break; |
|
| 104 | + $prefix_on_missing = true; |
|
| 105 | + $data = $this->replaceVars($data, $parameters, ",", null, true); |
|
| 106 | + break; |
|
| 107 | 107 | case "segments": |
| 108 | 108 | // Slash separated data. Bare values only. |
| 109 | 109 | $prefix = "/"; |
| 110 | - $data =$this->replaceVars($data, $parameters, "/"); |
|
| 111 | - break; |
|
| 110 | + $data =$this->replaceVars($data, $parameters, "/"); |
|
| 111 | + break; |
|
| 112 | 112 | case "dotprefix": |
| 113 | 113 | // Dot separated data. Bare values only. |
| 114 | 114 | $prefix = "."; |
| 115 | - $prefix_on_missing = true; |
|
| 116 | - $data = $this->replaceVars($data, $parameters, "."); |
|
| 117 | - break; |
|
| 115 | + $prefix_on_missing = true; |
|
| 116 | + $data = $this->replaceVars($data, $parameters, "."); |
|
| 117 | + break; |
|
| 118 | 118 | case "semicolon": |
| 119 | 119 | // Semicolon prefixed and separated. Uses the key name |
| 120 | 120 | $prefix = ";"; |
| 121 | - $data = $this->replaceVars($data, $parameters, ";", "=", false, true, false); |
|
| 122 | - break; |
|
| 121 | + $data = $this->replaceVars($data, $parameters, ";", "=", false, true, false); |
|
| 122 | + break; |
|
| 123 | 123 | case "form": |
| 124 | 124 | // Standard URL format. Uses the key name |
| 125 | 125 | $prefix = "?"; |
| 126 | - $data = $this->replaceVars($data, $parameters, "&", "="); |
|
| 127 | - break; |
|
| 126 | + $data = $this->replaceVars($data, $parameters, "&", "="); |
|
| 127 | + break; |
|
| 128 | 128 | case "continuation": |
| 129 | 129 | // Standard URL, but with leading ampersand. Uses key name. |
| 130 | 130 | $prefix = "&"; |
| 131 | - $data = $this->replaceVars($data, $parameters, "&", "="); |
|
| 132 | - break; |
|
| 133 | - } |
|
| 131 | + $data = $this->replaceVars($data, $parameters, "&", "="); |
|
| 132 | + break; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - // Add the initial prefix character if data is valid. |
|
| 136 | - if ($data || ($data !== false && $prefix_on_missing)) { |
|
| 135 | + // Add the initial prefix character if data is valid. |
|
| 136 | + if ($data || ($data !== false && $prefix_on_missing)) { |
|
| 137 | 137 | $data = $prefix . $data; |
| 138 | - } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | 140 | } else { |
| 141 | - // If no operator we replace with the defaults. |
|
| 142 | - $data = $this->replaceVars($data, $parameters); |
|
| 141 | + // If no operator we replace with the defaults. |
|
| 142 | + $data = $this->replaceVars($data, $parameters); |
|
| 143 | 143 | } |
| 144 | 144 | // This is chops out the {...} and replaces with the new section. |
| 145 | 145 | return substr($string, 0, $start) . $data . substr($string, $end + 1); |
| 146 | - } |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - private function replaceVars( |
|
| 149 | - $section, |
|
| 150 | - $parameters, |
|
| 151 | - $sep = ",", |
|
| 152 | - $combine = null, |
|
| 153 | - $reserved = false, |
|
| 154 | - $tag_empty = false, |
|
| 155 | - $combine_on_empty = true |
|
| 156 | - ) { |
|
| 148 | + private function replaceVars( |
|
| 149 | + $section, |
|
| 150 | + $parameters, |
|
| 151 | + $sep = ",", |
|
| 152 | + $combine = null, |
|
| 153 | + $reserved = false, |
|
| 154 | + $tag_empty = false, |
|
| 155 | + $combine_on_empty = true |
|
| 156 | + ) { |
|
| 157 | 157 | if (strpos($section, ",") === false) { |
| 158 | - // If we only have a single value, we can immediately process. |
|
| 159 | - return $this->combine( |
|
| 160 | - $section, |
|
| 161 | - $parameters, |
|
| 162 | - $sep, |
|
| 163 | - $combine, |
|
| 164 | - $reserved, |
|
| 165 | - $tag_empty, |
|
| 166 | - $combine_on_empty |
|
| 167 | - ); |
|
| 158 | + // If we only have a single value, we can immediately process. |
|
| 159 | + return $this->combine( |
|
| 160 | + $section, |
|
| 161 | + $parameters, |
|
| 162 | + $sep, |
|
| 163 | + $combine, |
|
| 164 | + $reserved, |
|
| 165 | + $tag_empty, |
|
| 166 | + $combine_on_empty |
|
| 167 | + ); |
|
| 168 | 168 | } else { |
| 169 | - // If we have multiple values, we need to split and loop over them. |
|
| 170 | - // Each is treated individually, then glued together with the |
|
| 171 | - // separator character. |
|
| 172 | - $vars = explode(",", $section); |
|
| 173 | - return $this->combineList( |
|
| 174 | - $vars, |
|
| 175 | - $sep, |
|
| 176 | - $parameters, |
|
| 177 | - $combine, |
|
| 178 | - $reserved, |
|
| 179 | - false, // Never emit empty strings in multi-param replacements |
|
| 180 | - $combine_on_empty |
|
| 181 | - ); |
|
| 169 | + // If we have multiple values, we need to split and loop over them. |
|
| 170 | + // Each is treated individually, then glued together with the |
|
| 171 | + // separator character. |
|
| 172 | + $vars = explode(",", $section); |
|
| 173 | + return $this->combineList( |
|
| 174 | + $vars, |
|
| 175 | + $sep, |
|
| 176 | + $parameters, |
|
| 177 | + $combine, |
|
| 178 | + $reserved, |
|
| 179 | + false, // Never emit empty strings in multi-param replacements |
|
| 180 | + $combine_on_empty |
|
| 181 | + ); |
|
| 182 | + } |
|
| 182 | 183 | } |
| 183 | - } |
|
| 184 | 184 | |
| 185 | - public function combine( |
|
| 186 | - $key, |
|
| 187 | - $parameters, |
|
| 188 | - $sep, |
|
| 189 | - $combine, |
|
| 190 | - $reserved, |
|
| 191 | - $tag_empty, |
|
| 192 | - $combine_on_empty |
|
| 193 | - ) { |
|
| 185 | + public function combine( |
|
| 186 | + $key, |
|
| 187 | + $parameters, |
|
| 188 | + $sep, |
|
| 189 | + $combine, |
|
| 190 | + $reserved, |
|
| 191 | + $tag_empty, |
|
| 192 | + $combine_on_empty |
|
| 193 | + ) { |
|
| 194 | 194 | $length = false; |
| 195 | 195 | $explode = false; |
| 196 | 196 | $skip_final_combine = false; |
@@ -198,136 +198,136 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | // Check for length restriction. |
| 200 | 200 | if (strpos($key, ":") !== false) { |
| 201 | - list($key, $length) = explode(":", $key); |
|
| 201 | + list($key, $length) = explode(":", $key); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | // Check for explode parameter. |
| 205 | 205 | if ($key[strlen($key) - 1] == "*") { |
| 206 | - $explode = true; |
|
| 207 | - $key = substr($key, 0, -1); |
|
| 208 | - $skip_final_combine = true; |
|
| 206 | + $explode = true; |
|
| 207 | + $key = substr($key, 0, -1); |
|
| 208 | + $skip_final_combine = true; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | // Define the list separator. |
| 212 | 212 | $list_sep = $explode ? $sep : ","; |
| 213 | 213 | |
| 214 | 214 | if (isset($parameters[$key])) { |
| 215 | - $data_type = $this->getDataType($parameters[$key]); |
|
| 216 | - switch ($data_type) { |
|
| 215 | + $data_type = $this->getDataType($parameters[$key]); |
|
| 216 | + switch ($data_type) { |
|
| 217 | 217 | case self::TYPE_SCALAR: |
| 218 | 218 | $value = $this->getValue($parameters[$key], $length); |
| 219 | - break; |
|
| 219 | + break; |
|
| 220 | 220 | case self::TYPE_LIST: |
| 221 | 221 | $values = array(); |
| 222 | - foreach ($parameters[$key] as $pkey => $pvalue) { |
|
| 222 | + foreach ($parameters[$key] as $pkey => $pvalue) { |
|
| 223 | 223 | $pvalue = $this->getValue($pvalue, $length); |
| 224 | 224 | if ($combine && $explode) { |
| 225 | - $values[$pkey] = $key . $combine . $pvalue; |
|
| 225 | + $values[$pkey] = $key . $combine . $pvalue; |
|
| 226 | 226 | } else { |
| 227 | - $values[$pkey] = $pvalue; |
|
| 227 | + $values[$pkey] = $pvalue; |
|
| 228 | + } |
|
| 228 | 229 | } |
| 229 | - } |
|
| 230 | - $value = implode($list_sep, $values); |
|
| 231 | - if ($value == '') { |
|
| 230 | + $value = implode($list_sep, $values); |
|
| 231 | + if ($value == '') { |
|
| 232 | 232 | return ''; |
| 233 | - } |
|
| 234 | - break; |
|
| 233 | + } |
|
| 234 | + break; |
|
| 235 | 235 | case self::TYPE_MAP: |
| 236 | 236 | $values = array(); |
| 237 | - foreach ($parameters[$key] as $pkey => $pvalue) { |
|
| 237 | + foreach ($parameters[$key] as $pkey => $pvalue) { |
|
| 238 | 238 | $pvalue = $this->getValue($pvalue, $length); |
| 239 | 239 | if ($explode) { |
| 240 | - $pkey = $this->getValue($pkey, $length); |
|
| 241 | - $values[] = $pkey . "=" . $pvalue; // Explode triggers = combine. |
|
| 240 | + $pkey = $this->getValue($pkey, $length); |
|
| 241 | + $values[] = $pkey . "=" . $pvalue; // Explode triggers = combine. |
|
| 242 | 242 | } else { |
| 243 | - $values[] = $pkey; |
|
| 244 | - $values[] = $pvalue; |
|
| 243 | + $values[] = $pkey; |
|
| 244 | + $values[] = $pvalue; |
|
| 245 | 245 | } |
| 246 | - } |
|
| 247 | - $value = implode($list_sep, $values); |
|
| 248 | - if ($value == '') { |
|
| 246 | + } |
|
| 247 | + $value = implode($list_sep, $values); |
|
| 248 | + if ($value == '') { |
|
| 249 | 249 | return false; |
| 250 | - } |
|
| 251 | - break; |
|
| 252 | - } |
|
| 250 | + } |
|
| 251 | + break; |
|
| 252 | + } |
|
| 253 | 253 | } else if ($tag_empty) { |
| 254 | - // If we are just indicating empty values with their key name, return that. |
|
| 255 | - return $key; |
|
| 254 | + // If we are just indicating empty values with their key name, return that. |
|
| 255 | + return $key; |
|
| 256 | 256 | } else { |
| 257 | - // Otherwise we can skip this variable due to not being defined. |
|
| 258 | - return false; |
|
| 257 | + // Otherwise we can skip this variable due to not being defined. |
|
| 258 | + return false; |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | if ($reserved) { |
| 262 | - $value = str_replace($this->reservedEncoded, $this->reserved, $value); |
|
| 262 | + $value = str_replace($this->reservedEncoded, $this->reserved, $value); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // If we do not need to include the key name, we just return the raw |
| 266 | 266 | // value. |
| 267 | 267 | if (!$combine || $skip_final_combine) { |
| 268 | - return $value; |
|
| 268 | + return $value; |
|
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | // Else we combine the key name: foo=bar, if value is not the empty string. |
| 272 | 272 | return $key . ($value != '' || $combine_on_empty ? $combine . $value : ''); |
| 273 | - } |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - /** |
|
| 276 | - * Return the type of a passed in value |
|
| 277 | - */ |
|
| 278 | - private function getDataType($data) |
|
| 279 | - { |
|
| 275 | + /** |
|
| 276 | + * Return the type of a passed in value |
|
| 277 | + */ |
|
| 278 | + private function getDataType($data) |
|
| 279 | + { |
|
| 280 | 280 | if (is_array($data)) { |
| 281 | - reset($data); |
|
| 282 | - if (key($data) !== 0) { |
|
| 281 | + reset($data); |
|
| 282 | + if (key($data) !== 0) { |
|
| 283 | 283 | return self::TYPE_MAP; |
| 284 | - } |
|
| 285 | - return self::TYPE_LIST; |
|
| 284 | + } |
|
| 285 | + return self::TYPE_LIST; |
|
| 286 | 286 | } |
| 287 | 287 | return self::TYPE_SCALAR; |
| 288 | - } |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - /** |
|
| 291 | - * Utility function that merges multiple combine calls |
|
| 292 | - * for multi-key templates. |
|
| 293 | - */ |
|
| 294 | - private function combineList( |
|
| 295 | - $vars, |
|
| 296 | - $sep, |
|
| 297 | - $parameters, |
|
| 298 | - $combine, |
|
| 299 | - $reserved, |
|
| 300 | - $tag_empty, |
|
| 301 | - $combine_on_empty |
|
| 302 | - ) { |
|
| 290 | + /** |
|
| 291 | + * Utility function that merges multiple combine calls |
|
| 292 | + * for multi-key templates. |
|
| 293 | + */ |
|
| 294 | + private function combineList( |
|
| 295 | + $vars, |
|
| 296 | + $sep, |
|
| 297 | + $parameters, |
|
| 298 | + $combine, |
|
| 299 | + $reserved, |
|
| 300 | + $tag_empty, |
|
| 301 | + $combine_on_empty |
|
| 302 | + ) { |
|
| 303 | 303 | $ret = array(); |
| 304 | 304 | foreach ($vars as $var) { |
| 305 | - $response = $this->combine( |
|
| 306 | - $var, |
|
| 307 | - $parameters, |
|
| 308 | - $sep, |
|
| 309 | - $combine, |
|
| 310 | - $reserved, |
|
| 311 | - $tag_empty, |
|
| 312 | - $combine_on_empty |
|
| 313 | - ); |
|
| 314 | - if ($response === false) { |
|
| 305 | + $response = $this->combine( |
|
| 306 | + $var, |
|
| 307 | + $parameters, |
|
| 308 | + $sep, |
|
| 309 | + $combine, |
|
| 310 | + $reserved, |
|
| 311 | + $tag_empty, |
|
| 312 | + $combine_on_empty |
|
| 313 | + ); |
|
| 314 | + if ($response === false) { |
|
| 315 | 315 | continue; |
| 316 | - } |
|
| 317 | - $ret[] = $response; |
|
| 316 | + } |
|
| 317 | + $ret[] = $response; |
|
| 318 | 318 | } |
| 319 | 319 | return implode($sep, $ret); |
| 320 | - } |
|
| 320 | + } |
|
| 321 | 321 | |
| 322 | - /** |
|
| 323 | - * Utility function to encode and trim values |
|
| 324 | - */ |
|
| 325 | - private function getValue($value, $length) |
|
| 326 | - { |
|
| 322 | + /** |
|
| 323 | + * Utility function to encode and trim values |
|
| 324 | + */ |
|
| 325 | + private function getValue($value, $length) |
|
| 326 | + { |
|
| 327 | 327 | if ($length) { |
| 328 | - $value = substr($value, 0, $length); |
|
| 328 | + $value = substr($value, 0, $length); |
|
| 329 | 329 | } |
| 330 | 330 | $value = rawurlencode($value); |
| 331 | 331 | return $value; |
| 332 | - } |
|
| 332 | + } |
|
| 333 | 333 | } |
@@ -17,52 +17,52 @@ |
||
| 17 | 17 | |
| 18 | 18 | class Google_Service_Exception extends Google_Exception |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * Optional list of errors returned in a JSON body of an HTTP error response. |
|
| 22 | - */ |
|
| 23 | - protected $errors = array(); |
|
| 20 | + /** |
|
| 21 | + * Optional list of errors returned in a JSON body of an HTTP error response. |
|
| 22 | + */ |
|
| 23 | + protected $errors = array(); |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Override default constructor to add the ability to set $errors and a retry |
|
| 27 | - * map. |
|
| 28 | - * |
|
| 29 | - * @param string $message |
|
| 30 | - * @param int $code |
|
| 31 | - * @param Exception|null $previous |
|
| 32 | - * @param [{string, string}] errors List of errors returned in an HTTP |
|
| 33 | - * response. Defaults to []. |
|
| 34 | - * @param array|null $retryMap Map of errors with retry counts. |
|
| 35 | - */ |
|
| 36 | - public function __construct( |
|
| 37 | - $message, |
|
| 38 | - $code = 0, |
|
| 39 | - Exception $previous = null, |
|
| 40 | - $errors = array() |
|
| 41 | - ) { |
|
| 25 | + /** |
|
| 26 | + * Override default constructor to add the ability to set $errors and a retry |
|
| 27 | + * map. |
|
| 28 | + * |
|
| 29 | + * @param string $message |
|
| 30 | + * @param int $code |
|
| 31 | + * @param Exception|null $previous |
|
| 32 | + * @param [{string, string}] errors List of errors returned in an HTTP |
|
| 33 | + * response. Defaults to []. |
|
| 34 | + * @param array|null $retryMap Map of errors with retry counts. |
|
| 35 | + */ |
|
| 36 | + public function __construct( |
|
| 37 | + $message, |
|
| 38 | + $code = 0, |
|
| 39 | + Exception $previous = null, |
|
| 40 | + $errors = array() |
|
| 41 | + ) { |
|
| 42 | 42 | if (version_compare(PHP_VERSION, '5.3.0') >= 0) { |
| 43 | - parent::__construct($message, $code, $previous); |
|
| 43 | + parent::__construct($message, $code, $previous); |
|
| 44 | 44 | } else { |
| 45 | - parent::__construct($message, $code); |
|
| 45 | + parent::__construct($message, $code); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | $this->errors = $errors; |
| 49 | - } |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * An example of the possible errors returned. |
|
| 53 | - * |
|
| 54 | - * { |
|
| 55 | - * "domain": "global", |
|
| 56 | - * "reason": "authError", |
|
| 57 | - * "message": "Invalid Credentials", |
|
| 58 | - * "locationType": "header", |
|
| 59 | - * "location": "Authorization", |
|
| 60 | - * } |
|
| 61 | - * |
|
| 62 | - * @return [{string, string}] List of errors return in an HTTP response or []. |
|
| 63 | - */ |
|
| 64 | - public function getErrors() |
|
| 65 | - { |
|
| 51 | + /** |
|
| 52 | + * An example of the possible errors returned. |
|
| 53 | + * |
|
| 54 | + * { |
|
| 55 | + * "domain": "global", |
|
| 56 | + * "reason": "authError", |
|
| 57 | + * "message": "Invalid Credentials", |
|
| 58 | + * "locationType": "header", |
|
| 59 | + * "location": "Authorization", |
|
| 60 | + * } |
|
| 61 | + * |
|
| 62 | + * @return [{string, string}] List of errors return in an HTTP response or []. |
|
| 63 | + */ |
|
| 64 | + public function getErrors() |
|
| 65 | + { |
|
| 66 | 66 | return $this->errors; |
| 67 | - } |
|
| 67 | + } |
|
| 68 | 68 | } |