use da.gd for short urls in sticky-notes stg
Signed-off-by: Ricky Elrod <codeblock@fedoraproject.org>
This commit is contained in:
parent
0e7a2d1c44
commit
aba414ad80
2 changed files with 46 additions and 0 deletions
39
roles/paste/files/class_urlshort_dagd.php
Normal file
39
roles/paste/files/class_urlshort_dagd.php
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Sticky Notes pastebin
|
||||||
|
* @ver 0.3
|
||||||
|
* @license BSD License - www.opensource.org/licenses/bsd-license.php
|
||||||
|
*
|
||||||
|
* Copyright (c) 2012 Sayak Banerjee <sayakb@kde.org>
|
||||||
|
* Copyright (c) 2013 Athmane Madjoudj <athmane@fedoraproject.org>
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -41,8 +41,15 @@
|
||||||
|
|
||||||
- name: timeout in case url.ca goes down
|
- name: timeout in case url.ca goes down
|
||||||
copy: src=class_urlshort.php dest=/usr/share/sticky-notes/classes/class_urlshort.php owner=root group=root mode=644
|
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
|
notify: reload httpd
|
||||||
|
|
||||||
|
- name: timeout in case url.ca goes down (with da.gd patch)
|
||||||
|
copy: src=class_urlshort.php dest=/usr/share/sticky-notes/classes/class_urlshort_dagd.php owner=root group=root mode=644
|
||||||
|
when: env == 'staging'
|
||||||
|
notify: reload httpd
|
||||||
|
|
||||||
|
|
||||||
- name: set sebooleans so paste can talk to the db
|
- name: set sebooleans so paste can talk to the db
|
||||||
seboolean: name=httpd_can_network_connect_db state=true persistent=true
|
seboolean: name=httpd_can_network_connect_db state=true persistent=true
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue