diff --git a/roles/paste/files/class_urlshort.php b/roles/paste/files/class_urlshort.php
index 0657725d50..6842f8db2e 100644
--- a/roles/paste/files/class_urlshort.php
+++ b/roles/paste/files/class_urlshort.php
@@ -16,21 +16,21 @@ class URLShortener
{
public function shorten($long_url)
{
+ // Don't shorten private pastes.
if(preg_match('/^http(s)?:\/\/(.+).fedoraproject.org\/(\d+)\/(\d+)\/$/', $long_url)) {
return $long_url;
}
$ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,"http://ur1.ca/");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('longurl' => $long_url)));
+ curl_setopt($ch, CURLOPT_URL,"https://da.gd/s");
+ curl_setopt($ch, CURLOPT_POST, 1);
+ curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('url' => $long_url)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,2);
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($ch, CURLOPT_TIMEOUT, 2);
$result = curl_exec($ch);
curl_close($ch);
- preg_match( '/
Your ur1 is: (.+)<\/a><\/p>/', $result, $match );
- if (!empty($match))
- return $match[1];
+ if (!empty($result))
+ return $result;
else
return false;
diff --git a/roles/paste/files/class_urlshort_dagd.php b/roles/paste/files/class_urlshort_dagd.php
deleted file mode 100644
index 48b0fd8add..0000000000
--- a/roles/paste/files/class_urlshort_dagd.php
+++ /dev/null
@@ -1,39 +0,0 @@
-
-* Copyright (c) 2013 Athmane Madjoudj
-* All rights reserved. Do not remove this copyright notice.
-*/
-
-/**
- * URL shortener using ur1.ca from Indenti.ca
- **/
-class URLShortener
-{
- public function shorten($long_url)
- {
- if(preg_match('/^http(s)?:\/\/(.+).fedoraproject.org\/(\d+)\/(\d+)\/$/', $long_url)) {
- return $long_url;
- }
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,"https://da.gd/s");
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array('url' => $long_url)));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 2);
- curl_setopt($ch, CURLOPT_TIMEOUT, 2);
- $result = curl_exec($ch);
- curl_close($ch);
- if (!empty($result))
- return $result;
- else
- return false;
-
- }
-}
-
-?>
diff --git a/roles/paste/tasks/main.yml b/roles/paste/tasks/main.yml
index 20d609a52f..a6d71bd962 100644
--- a/roles/paste/tasks/main.yml
+++ b/roles/paste/tasks/main.yml
@@ -39,17 +39,10 @@
copy: src=sticky-notes.ini dest=/etc/php.d/sticky-notes.ini owner=root group=root mode=644
notify: reload httpd
-- name: timeout in case url.ca goes down
+- name: Use da.gd instead of ur1.ca
copy: src=class_urlshort.php dest=/usr/share/sticky-notes/classes/class_urlshort.php owner=root group=root mode=644
- when: env != 'staging'
notify: reload httpd
-- name: timeout in case url.ca goes down (with da.gd patch)
- copy: src=class_urlshort_dagd.php dest=/usr/share/sticky-notes/classes/class_urlshort.php owner=root group=root mode=644
- when: env == 'staging'
- notify: reload httpd
-
-
- name: set sebooleans so paste can talk to the db
seboolean: name=httpd_can_network_connect_db state=true persistent=true