echo "Skipping tectonic summary.\n"; return; } $tectonicSql = configure('TECTONIC_SQL', $defaultScriptDir . DIRECTORY_SEPARATOR . 'tectonicsummary.sql', "Tectonic summary schema script"); $dbInstaller->runScript($tectonicSql); echo "Success!!\n"; // download tectonic summary data echo "\nDownloading and loading tectonic summary data:\n"; $url = configure('GLOBAL_TECTONIC_SUMMARY_URL', 'ftp://hazards.cr.usgs.gov/web/hazdev-geoserve-ws/tectonic/', "Tectonic summary download url"); $filenames = array('tectonicsummary_nc.dat', 'tectonicsummary_neic.dat', 'tectonicsummary_ut.dat'); $download_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tectonic_summary' . DIRECTORY_SEPARATOR; // create temp directory mkdir($download_path); foreach ($filenames as $filename) { $downloaded_file = $download_path . $filename; downloadURL($url . $filename, $downloaded_file); // uncompress tectonic summary data if (pathinfo($downloaded_file)['extension'] === 'zip') { print 'Extracting ' . $downloaded_file . "\n"; extractZip($downloaded_file, $download_path); } } // ---------------------------------------------------------------------- // Tectonic Summary data load // ---------------------------------------------------------------------- // Tectonic Summary echo "\nLoading tectonic summary data neic... "; $dbInstaller->copyFrom($download_path . 'tectonicsummary_neic.dat', 'tectonic_summary', array('NULL AS \'\'', 'CSV', 'HEADER')); echo "SUCCESS!!\n"; echo "\nLoading tectonic summary data nc... "; $dbInstaller->copyFrom($download_path . 'tectonicsummary_nc.dat', 'tectonic_summary', array('NULL AS \'\'', 'CSV', 'HEADER'));
$useVenue = 1; $useDateTaken = 1; $useDateUpload = 1; $useExtracted = 1; if (!$eventid) { $eventid = 151760; } if (!$output) { $output = 'php'; } if (!$eventInput) { $eventDataURL = 'http://prod1.yrb.scd.yahoo.com/8rlv2l5An3TL2Qs/happenings/eventInfo.php?eventid=' . $eventid; if ($debug == 1) { echo $eventDataURL; } $eventDetails = unserialize(downloadURL($eventDataURL)); } else { $eventInput = htmlspecialchars_decode($eventInput); $eventDetails = unserialize($eventInput); } if ($debug == 1) { show_keys($eventDetails); } $eventName = $eventDetails['event']['name']; $eventDate = $eventDetails['event']['start_date']; $eventVenue = $eventDetails['event']['venue_name']; $eventCity = $eventDetails['event']['venue_city']; $eventDescription = $eventDetails['event']['description']; $eventArtists = $eventDetails['event']['artists']; //get the youtube videos of the event foreach ($eventArtists as $artist) {
//get flickr pictures for the event $flickrSearchURL = $baseHappeningsAPI . 'flickrSearch.php?eventInput=' . urlencode($eventDetailsSerial); if ($debug == 1) { echo $flickrSearchURL; } $flickrPhotos = downloadURL($flickrSearchURL); $flickrPhotos = unserialize($flickrPhotos); if ($debug == 1) { show_keys($flickrPhotos); } //get youtube videos for the event $youtubeSearchURL = $baseHappeningsAPI . 'youtubeSearch.php?eventInput=' . urlencode($eventDetailsSerial); if ($debug == 1) { echo $youtubeSearchURL; } $youtubeVideos = downloadURL($youtubeSearchURL); $youtubeVideos = unserialize($youtubeVideos); if ($debug == 1) { show_keys($youtubeVideos); } $outputArray['event'] = $eventDetails['event']; $outputArray['media']['flickr'] = $flickrPhotos; $outputArray['media']['youtube'] = $youtubeVideos; if ($debug == 1) { show_keys($outputArray); } switch ($output) { case 'php': echo serialize($outputArray); break; case 'json':
function downloadAndUnzipAddons(&$addons) { foreach ($addons as $key => $addon) { if (!empty($addon['downloadLink'])) { $downloadLink = $addon['downloadLink']; //$fileMD5 = $updateDetails['fileMD5']; $zip = getTempName('addon_' . $addon['slug'] . '.zip'); appUpdateMsg('Downloading ' . $addon['slug'] . ' package...'); $isDone = downloadURL($downloadLink, $zip); if (!$isDone) { //download failed appUpdateMsg($addon['slug'] . ' package download failed.', true); continue; } if (!initFileSystem()) { appUpdateMsg('Unable to initiate file system.', true); return false; } $unPackResult = unPackToWorkingDir($zip); if (!empty($unPackResult) && is_array($unPackResult)) { $source = $unPackResult['source']; $remoteSource = $unPackResult['remoteSource']; } else { return false; } $destination = APP_ROOT; if (!copyToRequiredDir($source, $remoteSource, $destination)) { return false; } appUpdateMsg('Unzipped ' . $addon['slug'] . ' package.'); $addons[$key]['process']['unzipDone'] = true; @unlink($zip); } } //return $addons; }
// create or download content if (isset($content['bytes'])) { file_put_contents($file, $content['bytes']); } else { $url = $content['url']; if (strpos($url, $uploadPrefix) === 0) { // uploaded file is local $url = str_replace($uploadPrefix, '', $url); $uploadFile = realpath($uploadDir . DIRECTORY_SEPARATOR . $url); if (strpos($uploadFile, $uploadDir) === 0) { file_put_contents($file, file_get_contents($uploadFile)); } else { throw new Exception('The uploaded file must be in the upload ' . 'directory. ' . $uploadFile . ':' . $uploadDir); } } else { if (!downloadURL($url, $file, false)) { throw new Exception('Unable to download url ' . $content['url']); } } } // preserve last modified if (isset($content['lastModified'])) { touch($file, $content['lastModified'] / 1000); } } } // TODO: validate product // build product $sender->setSource($source); $sender->setType($type); $sender->setCode($code);
if (!is_dir($CONF_DIR)) { mkdir($CONF_DIR, 0755, true); } // Interactively prompts user for config. Writes CONFIG_FILE_INI include_once 'configure.inc.php'; // Parse the configuration $CONFIG = parse_ini_file($CONFIG_FILE_INI); // Write the HTTPD configuration file file_put_contents($HTTPD_CONF, ' ## autogenerated at ' . date('r') . ' Alias ' . $CONFIG['MOUNT_PATH'] . ' ' . $HTDOCS_DIR . ' <Location ' . $CONFIG['MOUNT_PATH'] . '> Order allow,deny Allow from all <LimitExcept GET> deny from all </LimitExcept> ExpiresActive on ExpiresDefault "access plus 1 days" </Location> '); include_once './functions.inc.php'; if (!file_exists($CONFIG['PDL_JAR_FILE'])) { if (promptYesNo('Download PDL Jar File?')) { downloadURL('http://ehppdl1.cr.usgs.gov/ProductClient/ProductClient.jar', $CONFIG['PDL_JAR_FILE']); } }