Skip to content

Commit

Permalink
Merge pull request chyrp#52 from toastwaffle/development
Browse files Browse the repository at this point in the history
Fixes issue chyrp#50
  • Loading branch information
jacklightbody committed Nov 13, 2011
2 parents ea83fcd + 78ac268 commit 5444616
Show file tree
Hide file tree
Showing 2 changed files with 145 additions and 96 deletions.
50 changes: 49 additions & 1 deletion modules/aggregator/aggregator.php
Expand Up @@ -23,6 +23,54 @@ static function __uninstall() {
Group::remove_permission("edit_aggregate");
Group::remove_permission("delete_aggregate");
}

function get_xml_remote($url) {
extract(parse_url($url), EXTR_SKIP);

if (ini_get("allow_url_fopen")) {
$context = stream_context_create(array('http'=>array('user_agent'=>"Chyrp/".CHYRP_VERSION)));
$content = @file_get_contents($url,false,$context);
if (!((strpos($http_response_header[0], " 200 ")) || (strpos($http_response_header[0], " 301 ")) || (strpos($http_response_header[0], " 302 ")) || (strpos($http_response_header[0], " 303 ")) || (strpos($http_response_header[0], " 307 "))))
$content = "Server returned a message: $http_response_header[0]";
} elseif (function_exists("curl_init")) {
$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);
curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, True);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handle, CURLOPT_TIMEOUT, 60);
curl_setopt($handle, CURLOPT_USERAGENT, 'Chyrp/'.CHYRP_VERSION);
$content = curl_exec($handle);
$status = curl_getinfo($handle, CURLINFO_HTTP_CODE);
curl_close($handle);
if (!(($status == 200) || ($status == 301) || ($status == 302) || ($status == 303) || ($status == 307)))
$content = "Server returned a message: $status";
} else {
$path = (!isset($path)) ? '/' : $path ;
if (isset($query)) $path.= '?'.$query;
$port = (isset($port)) ? $port : 80 ;

$connect = @fsockopen($host, $port, $errno, $errstr, 2);
if (!$connect) return false;

# Send the GET headers
fwrite($connect, "GET ".$path." HTTP/1.1\r\n");
fwrite($connect, "Host: ".$host."\r\n");
fwrite($connect, "User-Agent: Chyrp/".CHYRP_VERSION."\r\n\r\n");

$content = "";
while (!feof($connect)) {
$line = fgets($connect, 128);
if (preg_match("/\r\n/", $line)) continue;

$content.= $line;
}

fclose($connect);
}

return $content;
}

public function main_index($main) {
$config = Config::current();
Expand All @@ -37,7 +85,7 @@ public function main_index($main) {
foreach ($aggregates as $name => $feed) {
$xml_contents = preg_replace(array("/<(\/?)dc:date>/", "/xmlns=/"),
array("<\\1date>", "a="),
get_remote($feed["url"]));
$this->get_xml_remote($feed["url"]));
$xml = simplexml_load_string($xml_contents, "SimpleXMLElement", LIBXML_NOCDATA);

if ($xml === false)
Expand Down
191 changes: 96 additions & 95 deletions modules/aggregator/locale/en_US.pot
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Chyrp v2.1\n"
"Report-Msgid-Bugs-To: email@chyrp.net\n"
"POT-Creation-Date: 2011-01-10 22:17+0000\n"
"POT-Creation-Date: 2011-11-13 21:16+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FIRST LAST <EMAIL@EXAMPLE.COM>\n"
"Language-Team: LANGUAGE <EMAIL@EXAMPLE.COM>\n"
Expand All @@ -17,20 +17,27 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"

#: modules/aggregator/aggregator.php:374
#: modules/aggregator/aggregator.php:422
msgid "You can use XPath to navigate the feed and find the correct attribute."
msgstr ""

#: modules/aggregator/aggregator.php:12
msgid "Delete Aggregate"
msgstr ""

#: modules/aggregator/aggregator.php:347
msgid "Aggregate deleted."
#: modules/aggregator/pages/admin/manage_aggregates.twig:3
msgid "Manage Aggregates"
msgstr ""

#: modules/aggregator/aggregator.php:109
msgid "Aggregates"
#: modules/aggregator/pages/admin/new_aggregate.twig:31
#: modules/aggregator/pages/admin/edit_aggregate.twig:32
msgid "Scheduled"
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:10
#: modules/aggregator/pages/admin/edit_aggregate.twig:11
#: modules/aggregator/pages/admin/manage_aggregates.twig:9
msgid "Name"
msgstr ""

#: modules/aggregator/info.yaml:5
Expand All @@ -41,188 +48,182 @@ msgstr ""
msgid "Aggregator"
msgstr ""

#: modules/aggregator/pages/admin/manage_aggregates.twig:3
msgid "Manage Aggregates"
#: modules/aggregator/aggregator.php:395
msgid "Aggregate deleted."
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:10
#: modules/aggregator/pages/admin/manage_aggregates.twig:9
#: modules/aggregator/pages/admin/edit_aggregate.twig:11
msgid "Name"
#: modules/aggregator/aggregator.php:157
msgid "Aggregates"
msgstr ""

#: modules/aggregator/aggregator.php:379
#: modules/aggregator/pages/admin/new_aggregate.twig:14
#: modules/aggregator/pages/admin/edit_aggregate.twig:15
msgid "Source URL"
msgstr ""

#: modules/aggregator/aggregator.php:430
msgid "To call a function and use its return value for the post's value, use <code>call:</code>. Separate arguments with <code> || </code>."
msgstr ""

#: modules/aggregator/aggregator.php:380
#: modules/aggregator/aggregator.php:428
msgid "Functions"
msgstr ""

#: modules/aggregator/aggregator.php:370
#: modules/aggregator/aggregator.php:418
msgid "Use <a href=\"http://yaml.org/\">YAML</a> to specify what post attribute holds what value of the feed entry."
msgstr ""

#: modules/aggregator/aggregator.php:134
#: modules/aggregator/aggregator.php:182
msgid "Aggregation"
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:14
#: modules/aggregator/pages/admin/edit_aggregate.twig:15
msgid "Source URL"
#: modules/aggregator/pages/admin/new_aggregate.twig:30
#: modules/aggregator/pages/admin/edit_aggregate.twig:31
msgid "Private"
msgstr ""

#: modules/aggregator/aggregator.php:309
msgid "Aggregate updated."
#: modules/aggregator/pages/admin/new_aggregate.twig:29
#: modules/aggregator/pages/admin/edit_aggregate.twig:30
msgid "Public"
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:18
#: modules/aggregator/pages/admin/manage_aggregates.twig:10
#: modules/aggregator/pages/admin/edit_aggregate.twig:19
#: modules/aggregator/pages/admin/manage_aggregates.twig:10
msgid "Feather"
msgstr ""

#: modules/aggregator/aggregator.php:388
#: modules/aggregator/aggregator.php:357
msgid "Aggregate updated."
msgstr ""

#: modules/aggregator/pages/admin/aggregation_settings.twig:9
#, php-format
msgid "Check Feeds Every %s Minutes"
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:26
#: modules/aggregator/pages/admin/edit_aggregate.twig:27
#: modules/aggregator/pages/admin/manage_aggregates.twig:11
msgid "Default Status"
msgstr ""

#: modules/aggregator/aggregator.php:436
msgid "From the Photo feather:"
msgstr ""

#: modules/aggregator/aggregator.php:378
#: modules/aggregator/aggregator.php:426
msgid "To get the attribute of an element, use XPath to find it and the <code>.attr[]</code> syntax to grab an attribute."
msgstr ""

#: modules/aggregator/pages/admin/aggregation_settings.twig:9
#, php-format
msgid "Check Feeds Every %s Minutes"
#: modules/aggregator/pages/admin/new_aggregate.twig:34
#: modules/aggregator/pages/admin/edit_aggregate.twig:35
msgid "Group"
msgstr ""

#: modules/aggregator/aggregator.php:385
#: modules/aggregator/pages/admin/new_aggregate.twig:28
#: modules/aggregator/pages/admin/edit_aggregate.twig:29
msgid "Draft"
msgstr ""

#: modules/aggregator/aggregator.php:433
msgid "To get the URL of an image in the content"
msgstr ""

#: modules/aggregator/aggregator.php:264
#: modules/aggregator/aggregator.php:312
msgid "Aggregate created."
msgstr ""

#: modules/aggregator/aggregator.php:234
#: modules/aggregator/aggregator.php:282
msgid "You do not have sufficient privileges to add aggregates."
msgstr ""

#: modules/aggregator/aggregator.php:11
#: modules/aggregator/pages/admin/edit_aggregate.twig:3
#: modules/aggregator/pages/admin/edit_aggregate.twig:7
#: modules/aggregator/aggregator.php:11
msgid "Edit Aggregate"
msgstr ""

#: modules/aggregator/aggregator.php:387
#: modules/aggregator/pages/admin/new_aggregate.twig:52
#: modules/aggregator/pages/admin/edit_aggregate.twig:53
msgid "Post Attributes"
msgstr ""

#: modules/aggregator/aggregator.php:435
msgid "Example"
msgstr ""

#: modules/aggregator/aggregator.php:368
#: modules/aggregator/aggregator.php:416
msgid "Post Values"
msgstr ""

#: modules/aggregator/aggregator.php:272
#: modules/aggregator/aggregator.php:317
#: modules/aggregator/aggregator.php:340
#: modules/aggregator/aggregator.php:320
#: modules/aggregator/aggregator.php:365
#: modules/aggregator/aggregator.php:388
msgid "You do not have sufficient privileges to delete this aggregate."
msgstr ""

#: modules/aggregator/aggregator.php:269
#: modules/aggregator/aggregator.php:314
#: modules/aggregator/aggregator.php:331
#: modules/aggregator/aggregator.php:317
#: modules/aggregator/aggregator.php:362
#: modules/aggregator/aggregator.php:379
msgid "An ID is required to delete an aggregate."
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:52
#: modules/aggregator/pages/admin/edit_aggregate.twig:53
msgid "Post Attributes"
msgstr ""

#: modules/aggregator/aggregator.php:10
#: modules/aggregator/pages/admin/new_aggregate.twig:3
#: modules/aggregator/pages/admin/new_aggregate.twig:63
#: modules/aggregator/pages/admin/manage_aggregates.twig:57
#: modules/aggregator/aggregator.php:10
msgid "Add Aggregate"
msgstr ""

#: modules/aggregator/aggregator.php:372
msgid "XPath"
msgstr ""

#: modules/aggregator/pages/admin/manage_aggregates.twig:21
msgid "source"
msgstr ""

#: modules/aggregator/aggregator.php:345
msgid "Aggregate and its posts deleted."
#: modules/aggregator/aggregator.php:420
msgid "XPath"
msgstr ""

#: modules/aggregator/pages/admin/aggregation_settings.twig:10
msgid "disable"
msgstr ""

#: modules/aggregator/aggregator.php:384
msgid "To upload an image from the content"
msgstr ""

#: modules/aggregator/aggregator.php:383
msgid "The Aggregator module provides a couple helper functions:"
#: modules/aggregator/pages/admin/new_aggregate.twig:32
#: modules/aggregator/pages/admin/edit_aggregate.twig:33
msgid "Registered Only"
msgstr ""

#: modules/aggregator/aggregator.php:376
msgid "Attributes"
#: modules/aggregator/aggregator.php:393
msgid "Aggregate and its posts deleted."
msgstr ""

#: modules/aggregator/pages/admin/aggregation_settings.twig:3
msgid "Aggregation Settings"
msgstr ""

#: modules/aggregator/info.yaml:7
msgid "Pulls content RSS2/Atom feeds into your Chyrp installation as posts."
#: modules/aggregator/aggregator.php:432
msgid "To upload an image from the content"
msgstr ""

#: modules/aggregator/aggregator.php:431
msgid "The Aggregator module provides a couple helper functions:"
msgstr ""

#: modules/aggregator/aggregator.php:424
msgid "Attributes"
msgstr ""

#: modules/aggregator/pages/admin/manage_aggregates.twig:13
msgid "Last Update"
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:43
#: modules/aggregator/pages/admin/manage_aggregates.twig:12
#: modules/aggregator/pages/admin/edit_aggregate.twig:44
#: modules/aggregator/pages/admin/manage_aggregates.twig:12
msgid "Author"
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:26
#: modules/aggregator/pages/admin/manage_aggregates.twig:11
#: modules/aggregator/pages/admin/edit_aggregate.twig:27
msgid "Default Status"
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:28
#: modules/aggregator/pages/admin/edit_aggregate.twig:29
msgid "Draft"
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:29
#: modules/aggregator/pages/admin/edit_aggregate.twig:30
msgid "Public"
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:30
#: modules/aggregator/pages/admin/edit_aggregate.twig:31
msgid "Private"
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:31
#: modules/aggregator/pages/admin/edit_aggregate.twig:32
msgid "Scheduled"
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:32
#: modules/aggregator/pages/admin/edit_aggregate.twig:33
msgid "Registered Only"
#: modules/aggregator/info.yaml:7
msgid "Pulls content RSS2/Atom feeds into your Chyrp installation as posts."
msgstr ""

#: modules/aggregator/pages/admin/new_aggregate.twig:33
#: modules/aggregator/pages/admin/edit_aggregate.twig:34
msgid "Group"
msgstr ""

0 comments on commit 5444616

Please sign in to comment.