Example #1
0
     $connect = \shgysk8zer0\Core\resources\Parser::parseFile('connect.json');
     $DB->restore($connect->database) ? $resp->notify('Success', "The database has been restored from {$connect->database}.sql", 'images/icons/db.png')->reload() : $resp->notify('Failed', "There was a problem restoring from {$connect->database}.sql", 'images/icons/db.png');
     break;
 case 'backup database':
     require_login('admin');
     $connect = \shgysk8zer0\Core\resources\Parser::parseFile('connect.json');
     $DB->dump() ? $resp->notify('Success', "The database has been backed up to {$connect->database}.sql", 'images/icons/db.png') : $resp->notify("Unable to backup to {$connect->database}.sql", 'Check file permissions', 'images/icons/db.png');
     break;
 case 'update_sitemap':
     require_login('admin');
     update_sitemap();
     $resp->notify('Sitemap has been updated', 'View ' . URL . 'sitemap.xml', 'images/icons/db.png');
     break;
 case 'update_rss':
     require_login('admin');
     update_rss();
     $resp->notify('Rss Feed has been updated', 'View ' . URL . 'feed.rss', 'images/icons/db.png');
     break;
 case 'keep-alive':
     $resp->log('Kept-alive @ ' . date('h:i A'));
     break;
 case 'tracking_header_check':
     $headers = getallheaders();
     if (https()) {
         $resp->notify('Your connection is encrypted', 'The tracking header is only injected for non-encrypted traffic');
     } elseif (array_key_exists('X-UIDH', $headers)) {
         $resp->notify('Your carrier is tracking you!', 'Your tracking ID is ' . $headers['X-UIDH']);
     } else {
         $resp->notify('No tracking headers found.', 'This only tests for one specific header, and does not mean that another doesn\'t exist');
     }
     break;
    //var_dump($rss);
    // get only the first item
    $items = array_slice($rss->items, 0, 1);
    $current_items = array();
    foreach ($items as $item) {
        $url = $item['guid'];
        $url = make_bitly_url($url);
        /*$pos = strpos($url, '#post-');
          if ($pos !== false) {
              preg_match('/#post-([0-9]*)/', $url, $matches);
              $id = $matches[1];
              //$url = " http://uncovery.me/?p=$id";
          }*/
        $text = "New {$type}: {$item['title']} {$url} by {$item['dc']['creator']}";
        //echo $text;
        update_rss($text, $type);
    }
}
function make_bitly_url($url, $format = 'xml', $version = '2.0.1')
{
    $appkey = 'R_7885c7338712a9f1f6852a9bd0655b7b';
    $login = '******';
    //create the URL
    $bitly = 'http://api.bit.ly/shorten?version=' . $version . '&longUrl=' . urlencode($url) . '&login='******'&apiKey=' . $appkey . '&format=' . $format;
    //get the url
    //could also use cURL here
    $response = file_get_contents($bitly);
    if (!$response) {
        echo "Bit.ly unavailable";
        return $url;
    }