예제 #1
0
 /**
  * Fills up the shorturls hash with shorturls identified by service name. 
  */
 function put_shorturl($service, $url, &$shorturls)
 {
     global $serendipity;
     switch ($service) {
         case 'linktrimmer':
             if (class_exists('serendipity_event_linktrimmer')) {
                 $res = serendipity_db_query("SELECT value FROM `serendipity_config` WHERE name LIKE 'serendipity_event_linktrimmer:%/prefix';", true, 'assoc');
                 if (is_array($res) && !empty($res['value'])) {
                     $lt_prefix = "/" . trim($res['value']) . "/";
                 }
                 $res = serendipity_db_query("SELECT value FROM `serendipity_config` WHERE name LIKE 'serendipity_event_linktrimmer:%/domain';", true, 'assoc');
                 if (is_array($res) && !empty($res['value'])) {
                     $lt_domain = trim($res['value']);
                 }
                 if (empty($lt_domain)) {
                     $lt_domain = $serendipity['baseURL'];
                 }
                 if (empty($lt_prefix)) {
                     $lt_prefix = '/s/';
                 }
                 if ($lt_domain == $serendipity['baseURL']) {
                     $shorturls['linktrimmer'] = $lt_domain . $lt_prefix . trim(serendipity_event_linktrimmer::lookup($url));
                 } else {
                     $shorturls['linktrimmer'] = $lt_domain . trim(serendipity_event_linktrimmer::lookup($url));
                 }
             }
             break;
         case 'raw':
             $shorturls['raw'] = $url;
             break;
         case 'tinyurl':
             UrlShortener::shorten_via_tinyurl($url, $shorturls);
             break;
         case '7ax.de':
             UrlShortener::shorten_via_7ax($url, $shorturls);
             break;
         case 'isgd':
             UrlShortener::shorten_via_isgd($url, $shorturls);
             break;
         case 'bitly':
             UrlShortener::shorten_via_bitly($url, $shorturls);
             break;
         case 'yourls':
             UrlShortener::shorten_via_yourls($url, $shorturls);
             break;
         case 'jmp':
             UrlShortener::shorten_via_jmp($url, $shorturls);
             break;
         case 'delivr':
             UrlShortener::shorten_via_delivr($url, $shorturls);
             break;
         case 'twurl':
             UrlShortener::shorten_via_twurl($url, $shorturls);
             break;
         case 'piratly':
             UrlShortener::shorten_via_piratly($url, $shorturls);
             break;
             // old removed service
         // old removed service
         case 'snipr':
         case 'tr.im':
         case 'cli.gs':
             UrlShortener::shorten_via_7ax($url, $shorturls);
             break;
     }
 }