} } //danh cho source flikr if (JRequest::getString('flickrAPI')) { $params = array( 'api_key' => JRequest::getString('flickrAPI'), 'format' => 'php_serial' ); $arrPhotoSetIDs = array(); if (!JRequest::getString('photosetid')) { //lay user id tu username $params['method'] = 'flickr.people.findByEmail'; $params['find_email'] = JRequest::getString('flickrUserID'); $encoded_params = array(); foreach ($params as $k => $v) { $encoded_params[] = urlencode($k) . '=' . urlencode($v); } $url = "http://api.flickr.com/services/rest/?" . implode('&', $encoded_params); $rsp = file_get_contents($url); $objRSP = unserialize($rsp); if ($objRSP['stat'] == 'ok') { $params['user_id'] = $objRSP['user']['id']; } $params['method'] = 'flickr.photosets.getList'; $encoded_params = array(); foreach ($params as $k => $v) { $encoded_params[] = urlencode($k) . '=' . urlencode($v); } $url = "http://api.flickr.com/services/rest/?" . implode('&', $encoded_params); $rsp = file_get_contents($url); $objRSP = unserialize($rsp); if ($objRSP['stat'] == 'ok') { foreach ($objRSP['photosets']['photoset'] as $photoSet) { $arrPhotoSetIDs[$photoSet['id']] = $photoSet['title']['_content']; } } else { $this->result["message"] = $objRSP['message']; } } else { $params['method'] = 'flickr.photosets.getInfo'; $params['photoset_id'] = JRequest::getString('photosetid'); $encoded_params = array(); foreach ($params as $k => $v) { $encoded_params[] = urlencode($k) . '=' . urlencode($v); } $url = "http://api.flickr.com/services/rest/?" . implode('&', $encoded_params); $rsp = file_get_contents($url); $objRSP = unserialize($rsp); if ($objRSP['stat'] == 'ok') { $arrPhotoSetIDs[JRequest::getString('photosetid')] = $objRSP['photoset']['title']['_content']; } else { $this->result["message"] = $objRSP['message']; } } foreach ($arrPhotoSetIDs as $photoSetID => $photoSetName) { $params['method'] = 'flickr.photosets.getPhotos'; $params['photoset_id'] = $photoSetID; $encoded_params = array(); foreach ($params as $k => $v) { $encoded_params[] = urlencode($k) . '=' . urlencode($v); } $url = "http://api.flickr.com/services/rest/?" . implode('&', $encoded_params); $rsp = file_get_contents($url); $objRSP = unserialize($rsp); if ($objRSP['stat'] == 'ok') { foreach ($objRSP['photoset']['photo'] as $photo) { if (isset($photo['originalsecret']) && isset($photo['originalformat'])) { $file = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo->id . "_" . $photo['originalsecret'] . "_o." . $photo['originalformat']; } else { $file = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . "_b.jpg"; } $fileInfo = pathinfo($file); $hashedName = md5($moduleID . '-' . 'flickr-' . $photoSetName . '-' . $fileInfo['filename']); if ( $file && !JFile::exists($this->saveDir . "/tmp/original/{$hashedName}.{$fileInfo["extension"]}") && !in_array($hashedName . '.' . $fileInfo["extension"], $this->items) ) { $objFile = new stdClass(); $objFile->file = str_replace('http://', '', $file); $objFile->title = ($feedTitle) ? $photo['title'] : ''; $objFile->source = 'flickr-' . $photoSetName; $photos[] = $objFile; } } } else { $this->result["message"] = $objRSP['message']; } } } //if source is picasa if (JRequest::getString('picasaUserID')) { // build feed URL $userid = JRequest::getString('picasaUserID'); $arrFeedURLs = array(); if (JRequest::getString('albumid')) { $arrFeedURLs[] = 'http://picasaweb.google.com/data/feed/base/user/' . $userid . '/albumid/' . JRequest::getString('albumid') . '?alt=rss'; } else { $feedURL = 'http://picasaweb.google.com/data/feed/api/user/' . $userid . '?alt=rss&kind=album'; @$sxml = simplexml_load_file($feedURL); if (isset($sxml) && $sxml) { foreach ($sxml->channel->item as $entry) { $guid = (string) $entry->guid; $albumID = substr($guid, strrpos($guid, '/') + 1, strrpos($guid, '?') - 1 - strrpos($guid, '/')); $arrFeedURLs[] = 'http://picasaweb.google.com/data/feed/base/user/' . $userid . '/albumid/' . $albumID . '?alt=rss'; } } else { $this->result["success"] = false; $this->result['message'] = 'Unable to find user with email ' . $userid . '@gmail.com'; } } foreach ($arrFeedURLs as $feedURL) { $sxml = @simplexml_load_file($feedURL); if ($sxml) { foreach ($sxml->channel->item as $entry) { $media = $entry->children('http://search.yahoo.com/mrss/'); $file = (string) $media->group->content->attributes()->url; $fileInfo = pathinfo($file); $hashedName = md5($moduleID . '-' . 'picasa-' . (string) $sxml->channel->title . '-' . $fileInfo['filename']); if ( $file && !JFile::exists($this->saveDir . "/tmp/original/{$hashedName}.{$fileInfo["extension"]}") && !in_array($hashedName . '.' . $fileInfo["extension"], $this->items)